Bug ID: 30446
           Summary: Undefining __GNUC__ or setting __GNUC__ to 1 breaks
           Product: libc++
           Version: 3.4
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
    Classification: Unclassified

We are trying to stop Clang from pretending to be other compilers. We have
specific code paths for both LLVM and Apple Clang, and the constant application
of work-arounds because Clang cannot consume the same programs as GCC is
becoming tiresome.

When we add the following to our code it completely breaks things. Originally
we tried undefining __GNUC__ to get it out of "GCC code paths". Then we tried
setting it to 1 to give it a "minimal GCC configuration". Then we tried setting
it to 3 to obtain the "minimal GCC configuration".

Setting __GNUC__ to 4 gets Clang out of GCC 4.0.1, 4.1 and 4.2 code paths. That
allows some of the SSE3 and SSSE3 stuff to compile as expected. GCC added SSE3
support at GCC 4.1, but Clang fails to compile it.

Test program:

$ cat test.cxx 
#if defined(__GNUC__) && defined(__clang__)
# undef __GNUC__
# undef __GNUC_MINOR__
# define __GNUC__ 1

#include <string>
int main(int argc, char* argv[])
  return 0;


$ c++ -DNDEBUG -g2 -O2 -stdlib=libc++ test.cxx -o test.exe
In file included from test.cxx:8:
In file included from /usr/bin/../lib/c++/v1/string:435:
In file included from /usr/bin/../lib/c++/v1/iosfwd:90:
In file included from /usr/include/wchar.h:70:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:32:
/usr/include/sys/cdefs.h:81:2: warning: "Unsupported compiler detected"
#warning "Unsupported compiler detected"
1 warning generated.

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to