A small list of GCC Hacks
- g++ -o helloworld helloworld.cc produces helloworld binary from helloworld.cc C++ file.
- use -Wall switch turns on all warnings(potential errors) in the code (like unused variables)
- g++ -E helloworld.cc generates output code after the pre-processing stage.
- use -O1 switch for level 1 optimization and -O3 for level 3 optimization (very rigorous)
- use -Os switch for generating code which is small in size
- g++ -S helloworld.cc generates asm code helloworld.S
- g++ -DNAME=”ashish” helloworld.cc equivalent to writing #define NAME ashish in the code.
- cpp -dM /dev/null lists all gcc macros available on the system as a part of GCC standard (they all starts with two underscores)
Reference
- GCC man page
- CPP man page