Hi,
I am a newbie in C++ programming. When compiling I never use any option.
This is my day to day command:
g++ MyCode.cc -o MyCode
For safety practice what's the best option to use?
Hi,
I am a newbie in C++ programming. When compiling I never use any option.
This is my day to day command:
g++ MyCode.cc -o MyCode
For safety practice what's the best option to use?
“-Werror”: treats all warnings as errors so you have to fix them. Incredibly valuable.
g++ -W -Wall -Werror
Will display all errors and warnings possible and treat them as errors.
g++ -Wall -Weffc++ -Werror -pedantic
When I'm using Boost, though, I drop it down to:
g++ -Wall -Werror
I'm anxiously awaiting GCC 4.4 and 4.5, though. There are some features coming that I really badly need.
-pipe, it speeds up compilation a little bit. Also -O2, which speeds up execution.
I like -march=athlon -O2 -pipe
for building most programs (I run Gentoo at home), and I use -ansi -pedantic -Wall
for code I write myself.
-ansi -pedantic
-D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D_GNU_SOURCE -D_REENTRANT
-Wall -Wextra -Wwrite-strings -Winit-self -Wcast-align -Wcast-qual -Wold-style-cast -Wpointer-arith -Wstrict-aliasing -Wformat=2 -Wuninitialized -Wmissing-declarations -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long
-O3 -ftree-vectorize -ftree-vectorizer-verbose=2 -ffast-math -fstrict-aliasing -march=native/pentium4/nocona/core2 -msse2 -mfpmath=sse