Thank You, GCC!

by chromatic

I've found myself writing a lot of C code this year. I've come to appreciate the power of a good compiler, especially when trying to walk other people through compiling my supposedly cross-platform code on Windows with MSVC.

GCC may not always produce the fastest code or compile with the greatest speed, but it's reliable, and once I have code compiling with GCC on Linux, I have confidence that it will compile for just about any other free Unix with GCC.

I've also come to appreciate several GCC flags and options. For example, GCC 4.x added a compiler flag called -fvisibility=hidden. When you build a shared library with this flag, GCC will hide all symbols not explicitly marked as visible. As Windows DLLs require export lists of all symbols visible externally, enabling this feature for non-Windows compiles helps prevent me from adding a new symbol but forgetting to export it.

I'm also a fan of -Wc++-compat, which gives copious warnings about dubious constructs which may choke a C++ compiler. Again, not all platforms have good C compilers available (mostly by disallowing the use of GCC), so making my code as clean as possible helps avoid a large porting burden later.

I know there are other good tools to analyze code, but for the cost of a few compiler and linker flags, I get a good cross-section of warnings that help me clean up my code--and a high-quality, cross-platform compiler for free.

Thank you, everyone who's contributed to GCC.


3 Comments

jmmv
2007-07-11 00:38:41
I've tried to use -Wc++-compat on one of my projects, but g++ says that this option is not recognized. I'm using this GCC:


i686-apple-darwin8-g++-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367)


Which one are you using? Thanks!

jason
2007-07-11 10:06:39
Shameless self-promotion (yet fairly relevant): Ohloh lets people say thanks to individuals and open source projects. The GCC page is here: http://www.ohloh.net/projects/15.


Just "stack" the apps you like, or, more specifically, give "Kudos" to individual contributors.

chromatic
2007-07-11 11:09:45
@jmmv, the flag only works with gcc, and then I believe only if you use the -Wall flag. With g++, you're already using a C++ compiler, so it should automatically warn about dubious constructs if you've enabled warnings.