Patch #3417 2013-02-02 04:52

hsolter

Disable the definition of nullptr_t when using clang
Download
3417-Disable_the_de.patch (600 bytes)
Category
Application::Bugfix
Status
Accepted
Close date
2013-05-08 19:39
Assigned to
alpha0010
Index: src/include/prep.h
===================================================================
--- src/include/prep.h    (revision 8813)
+++ src/include/prep.h    (working copy)
@@ -9,8 +9,12 @@
 #ifndef wxMAJOR_VERSION
     #include <wx/version.h>
 #endif
+#ifndef __has_feature
+    #define __has_feature(x) 0
+#endif
 
-#if !(__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined __GXX_EXPERIMENTAL_CXX0X__)
+#if !(__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined __GXX_EXPERIMENTAL_CXX0X__) \
+    && !(__clang__ && __has_feature(cxx_nullptr))
     // it is a const object...
     const class nullptr_t
     {
hsolter 2013-02-02 04:55

Unlike g++, nullptr_t is defined when using clang in cxx mode which causes compilation problems. Patch disables the class definition and macro when using clang in cxx mode.

hsolter 2013-02-02 05:00

Unlike g++, nullptr_t is defined when using clang in cxx mode which causes compilation problems. Patch disables the class definition and macro when using clang in cxx mode.

alpha0010 2013-05-06 22:12

When does the problem occur? I have previously compiled Code::Blocks with Clang, and no errors occurred from nullptr_t.

hsolter 2013-05-07 16:44

You probably compiled it in c++2003 mode (the default) since the c++11 defines nullptr it gives error when -std=c++11 is defined.Patch fixs this just like the gcc.

hsolter 2013-05-07 16:55

Of course the real problem is the line

#define nullptr nullptr_

It is a bad idea to redefine a keyword..

hsolter 2013-05-07 17:00

Of course the real problem is the line

#define nullptr nullptr_

It is a bad idea to redefine a keyword..

alpha0010 2013-05-08 19:39

The reason Code::Blocks (conditionally) defines nullptr is to back-port this feature for people stuck on old compilers.

hsolter 2013-05-08 22:58

Of course I knew that. I was just pointing out the line that causes the problem in c++11 mode