Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
![](/static/devrant/img/pipeless-devrant-banner-white.png)
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Hazarth92595yMost programmers don't know about compiler flags because the IDE makes it essentially invisible :( and even if theres an option for all the flags, god forbid someone googled it or explored their IDE when they don't have to -_-
-
Fakerlol865y@Ranchu correct, you can specify an optimization-level (-O) with which the compiler tries to optimize for a specific goal (using less memory, faster code, smaller [code]size etc).
Well, at least can with gcc and mvc, guess llvm does support it as well, not sure though.
Higher levels can lead to bugs if you like to use aliasing or type punning though, so most devs are discouraged to even use them (according to the "if you don't know what it does, don't use it" addage).
Only works if you have access to the compiler flags though. If you're in a project with a makefile managed by someone else, it gets quite exhausting to argue about compiler flags....
And don't get me started about the volatile keyword. Even less devs know about it and when and how to use it. But I guess it's embedded specific so it stands to reason that it's not known by many :) -
Fakerlol865y@Ranchu Well I only ever used it with gcc, so I wouldn't know if it works with other compilers - at least with this specific flag.
I'm pretty sure that all C/++ compilers worth their name have some sort of optimization routines built in, one just has to find out how to use them.
Microsoft's has it, as you can change it through the properties of the project or with the corresponding flag (I think it was /O).
Another tidbit: When using an IDE without a makefile, usually choosing Debug-Mode will compile with O0 and choosing Release-Mode will compile with O3. You can spot this in the compilers' output :)
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911
Hats off to this lady .... I would have just flipped the machine
That time when I wowed all my colleagues with C++-code that executed over 2.5x faster than theirs, without changing one line of code.
I guess they didn't know what -O2 does (or that it exists, for that matter).
rant
genetic algorithm
c++
optimization
poor man's magic trick