[cfe-commits] [PATCH RFC] Stop defining __GNUC__ for MSVC builds

Aaron Ballman aaron at aaronballman.com
Fri Mar 2 16:16:51 PST 2012


There are a lot of references on the web which relate __GNUC__ to GCC
for compiler discovery
(<http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers#GCC_C.2FC.2B.2B>,
<http://www.ocf.berkeley.edu/~pad/tigcc/doc/html/cpp_SEC15_GNUC.html>,
etc).  This translates into a fair number of cross-compiler projects
with code like this:

#if defined(__GNUC__)
  // Do GCC things
#elif defined(_MSC_VER)
  // Do MSVC things
...
#endif

This currently leads to problems when compiling with Clang because
__GNUC__ (and friends) are always defined, even when compiling for MS
compatibility (PR 11790).  I've attached a patch which addresses this
by only defining __GNUC__ et al when MSVC mode is not set.  This means
code like the above will work as expected.

Thoughts?

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GnuC.patch
Type: application/octet-stream
Size: 1558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120302/a8b02e6f/attachment.obj>


More information about the cfe-commits mailing list