C++ switches -O2; -static; -lm ...
Moderator: Board moderators
C++ switches -O2; -static; -lm ...
Ok it would be very nice if someone would introduce us with c++ flags(-O2 -static -lm ...) Or atleast pass a link, because in google it is really hard to find any useful info abot because google is not able to find minus.
I know when -O2 flag is in use, my program is twice faster, but why?
And how to add switches in c++ source code, not in compiler command line!
I know when -O2 flag is in use, my program is twice faster, but why?
And how to add switches in c++ source code, not in compiler command line!
http://www.google.com/search?q=man+gcc

e.g. 'apple -banana' should return pages containing 'apple', but not containing 'banana'.
Well, you can't. A (very limited) substitution is #pragma directives.And how to add switches in c++ source code, not in compiler command line!
rotfl, minus tells google to exclude the word after the minus from the searchbecause in google it is really hard to find any useful info abot because google is not able to find minus.



e.g. 'apple -banana' should return pages containing 'apple', but not containing 'banana'.
Thanks a lot... Those keywords really helped me!mf wrote:http://www.google.com/search?q=man+gcc
Well, you can't. A (very limited) substitution is #pragma directives.And how to add switches in c++ source code, not in compiler command line!
rotfl, minus tells google to exclude the word after the minus from the searchbecause in google it is really hard to find any useful info abot because google is not able to find minus.![]()
![]()
e.g. 'apple -banana' should return pages containing 'apple', but not containing 'banana'.
Is there any way i can include swicth -O2 in source???
I mean something like "#pragma -O2"
I don't think it's possible with gcc.Is there any way i can include swicth -O2 in source???
I've heard that on some compilers you can control optimizations in this way:
Code: Select all
#pragma optimization_level X
While your answer is technically correct, I assume that the intended question here was "Can I do something to force the UVa compiler to optimize my code?"Moha wrote:The best way to use predefined option for all source code, (I don't recommand this) is use some system variable/ or writing a generic Make file.
And there, the answer is "No." and your suggestions don't help.
No You are wrong. I don`t need to optimize my code for uva... I believe that on-line judge automatically do that for me.misof wrote:While your answer is technically correct, I assume that the intended question here was "Can I do something to force the UVa compiler to optimize my code?"Moha wrote:The best way to use predefined option for all source code, (I don't recommand this) is use some system variable/ or writing a generic Make file.
And there, the answer is "No." and your suggestions don't help.