c - Determine optimization level in preprocessor? -


-og relatively new optimization option intended improve debugging experience while apply optimizations. if user selects -og, i'd source files activate alternate code paths enhance debugging experience. gcc offers __optimize__ preprocessor macro, set 1 when optimizations in effect.

is there way learn optimization level, -o1, -o3 or -og, use preprocessor?

i believe not possible know directly optimization level used compile software not in the list of defined preprocessor symbols

you rely on -dndebug (no debug) used disable assertions in release code , enable "debug" code path in case.

however, believe better thing having system wide set of symbols local project , let user choose use explicitly.:

  • myproject_dndebug
  • myproject_optimize
  • myproject_optimize_aggressively

this makes debugging or differences of behavior between release/debug easier can incrementally turn on/off different behaviors.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -