What's your favorite g++ option? [closed]

2019-03-12 01:19发布

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?

10条回答
家丑人穷心不美
2楼-- · 2019-03-12 01:37

Actually, it's a set: -Wall -pedantic -std=c++98

查看更多
爷、活的狠高调
3楼-- · 2019-03-12 01:38
g++ -W -Wall -Werror

Will display all errors and warnings possible and treat them as errors.

查看更多
forever°为你锁心
4楼-- · 2019-03-12 01:40
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.

查看更多
孤傲高冷的网名
5楼-- · 2019-03-12 01:47

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.

查看更多
地球回转人心会变
6楼-- · 2019-03-12 01:50
g++ -g 

I really need that debug information....

查看更多
迷人小祖宗
7楼-- · 2019-03-12 01:53

If you thought you caught everything, try -Wextra

查看更多
登录 后发表回答