User forums > Help

compilation of c::b fails in "compiler.cpp"

<< < (2/3) > >>

thomas:
I'm not happy with this. This is not a fix for a problem in our code, but a fix for a broken compiler (or system headers).

Non-double-underscore, non-leading-underscore-capital-letter identifier in non-global namespace (and not-leading-underscore idendifier in any namespace) are not reserved and may be used. What we are doing is correct.

The system header that defines linux should instead define _Linux or __linux or __linux__. Of course, if it doesn't, that's bad luck for someone trying to build Code::Blocks, but still the "fix" is not addressing the problem.

Look at it this way, some disturbed person might add #define if else or #define protected private to their system headers -- does that mean we're not allowed to use the if keyword and can't have protected members in our code?

Biplab:

--- Quote from: thomas on June 10, 2013, 11:02:24 am ---I'm not happy with this. This is not a fix for a problem in our code, but a fix for a broken compiler (or system headers).

Non-double-underscore, non-leading-underscore-capital-letter identifier in non-global namespace (and not-leading-underscore idendifier in any namespace) are not reserved and may be used. What we are doing is correct.

The system header that defines linux should instead define _Linux or __linux or __linux__. Of course, if it doesn't, that's bad luck for someone trying to build Code::Blocks, but still the "fix" is not addressing the problem.

Look at it this way, some disturbed person might add #define if else or #define protected private to their system headers -- does that mean we're not allowed to use the if keyword and can't have protected members in our code?

--- End quote ---

I knew that you won't like it. :)

However I decided to patch our code (or a hack in your words) as some users were facing build issue. As this is a known problem we better accept it and make necessary changes in our code.


If you still dislike then you can apply the following patch which correctly fixes this issue.

--- Code: ---Index: src/sdk/compiletargetbase.cpp
===================================================================
--- src/sdk/compiletargetbase.cpp (revision 9146)
+++ src/sdk/compiletargetbase.cpp (working copy)
@@ -264,7 +264,7 @@
             {
                 wxString prefix = wxEmptyString;
                 // On linux, "lib" is the common prefix for this platform
-                if (platform::Linux)
+                if (platform::linux)
                     prefix = wxT("lib");
                 // FIXME (mortenmacfly#5#): What about Mac (Windows is OK)?!
 
Index: src/sdk/compileoptionsbase.cpp
===================================================================
--- src/sdk/compileoptionsbase.cpp (revision 9146)
+++ src/sdk/compileoptionsbase.cpp (working copy)
@@ -64,7 +64,7 @@
 {
     if(platform::windows)
         return m_Platform & spWindows;
-    if(platform::Unix)
+    if(platform::unix)
         return m_Platform & spUnix;
     if(platform::macosx)
         return m_Platform & spMac;
Index: src/sdk/configmanager.cpp
===================================================================
--- src/sdk/configmanager.cpp (revision 9146)
+++ src/sdk/configmanager.cpp (working copy)
@@ -262,11 +262,11 @@
 
     if (platform::windows)
         info.append(_T("\n\t Windows "));
-    if (platform::Linux)
+    if (platform::linux)
         info.append(_T("\n\t Linux "));
     if (platform::macosx)
         info.append(_T("\n\t Mac OS X "));
-    if (platform::Unix)
+    if (platform::unix)
         info.append(_T("\n\t Unix "));
 
     info.append(platform::unicode ? _T("Unicode ") : _T("ANSI "));
Index: src/sdk/compiler.cpp
===================================================================
--- src/sdk/compiler.cpp (revision 9146)
+++ src/sdk/compiler.cpp (working copy)
@@ -1144,7 +1144,7 @@
         else if (test == wxT("macosx"))
             val = platform::macosx;
         else if (test == wxT("linux"))
-            val = platform::Linux;
+            val = platform::linux;
         else if (test == wxT("freebsd"))
             val = platform::freebsd;
         else if (test == wxT("netbsd"))
@@ -1156,7 +1156,7 @@
         else if (test == wxT("solaris"))
             val = platform::solaris;
         else if (test == wxT("unix"))
-            val = platform::Unix;
+            val = platform::unix;
     }
     else if (node->GetAttribute(wxT("exec"), &test))
     {
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp (revision 9146)
+++ src/sdk/editormanager.cpp (working copy)
@@ -3219,7 +3219,7 @@
             defines.Add(wxT("__WXOSX_MAC__"));
             defines.Add(wxT("__APPLE__"));
         }
-        else if (platform::Linux)
+        else if (platform::linux)
         {
             defines.Add(wxT("LINUX"));
             defines.Add(wxT("linux"));
@@ -3254,7 +3254,7 @@
             defines.Add(wxT("__SUNOS__"));
             defines.Add(wxT("__SOLARIS__"));
         }
-        if (platform::Unix)
+        if (platform::unix)
         {
             defines.Add(wxT("unix"));
             defines.Add(wxT("__unix"));
Index: src/plugins/projectsimporter/msvc10loader.cpp
===================================================================
--- src/plugins/projectsimporter/msvc10loader.cpp (revision 9146)
+++ src/plugins/projectsimporter/msvc10loader.cpp (working copy)
@@ -50,7 +50,7 @@
     //ctor
     if (platform::windows)
         m_PlatformName = _T("Win32");
-    else if (platform::Linux)
+    else if (platform::linux)
         m_PlatformName = _T("Linux");
     else if (platform::macosx)
         m_PlatformName = _T("MacOSX");
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 9146)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -919,7 +919,7 @@
                 else if (test == wxT("macosx"))
                     val = platform::macosx;
                 else if (test == wxT("linux"))
-                    val = platform::Linux;
+                    val = platform::linux;
                 else if (test == wxT("freebsd"))
                     val = platform::freebsd;
                 else if (test == wxT("netbsd"))
@@ -931,7 +931,7 @@
                 else if (test == wxT("solaris"))
                     val = platform::solaris;
                 else if (test == wxT("unix"))
-                    val = platform::Unix;
+                    val = platform::unix;
             }
             if (val)
                 CompilerFactory::RegisterCompiler(
Index: src/plugins/contrib/lib_finder/processingdlg.cpp
===================================================================
--- src/plugins/contrib/lib_finder/processingdlg.cpp (revision 9146)
+++ src/plugins/contrib/lib_finder/processingdlg.cpp (working copy)
@@ -423,7 +423,7 @@
                     }
                 }
 
-                if ( platform::Linux )
+                if ( platform::linux )
                 {
                     if ( Platform==_T("lin") || Platform==_T("linux") )
                     {
@@ -477,7 +477,7 @@
                     }
                 }
 
-                if ( platform::Unix )
+                if ( platform::unix )
                 {
                     if ( Platform==_T("unix") || Platform==_T("un*x") )
                     {
Index: src/include/prep.h
===================================================================
--- src/include/prep.h (revision 9146)
+++ src/include/prep.h (working copy)
@@ -135,9 +135,9 @@
     platform::id
         Value of type platform::identifier describing the target platform
 
-    platform::windows, platform::macosx, platform::Linux
+    platform::windows, platform::macosx, platform::linux
     platform::freebsd, platform::netbsd, platform::openbsd
-    platform::darwin,  platform::solaris, platform::Unix
+    platform::darwin,  platform::solaris, platform::unix
         Boolean value that evaluates to true if the target platform is the same as the variable's name, false otherwise.
         Using the platform booleans is equivalent to using platform::id, but results in nicer code.
 
@@ -218,13 +218,13 @@
 
     const bool windows = (id == platform_windows);
     const bool macosx  = (id == platform_macosx);
-    const bool Linux   = (id == platform_linux);
+    const bool linux   = (id == platform_linux);
     const bool freebsd = (id == platform_freebsd);
     const bool netbsd  = (id == platform_netbsd);
     const bool openbsd = (id == platform_openbsd);
     const bool darwin  = (id == platform_darwin);
     const bool solaris = (id == platform_solaris);
-    const bool Unix    = (Linux | freebsd | netbsd | openbsd | darwin | solaris);
+    const bool unix    = (linux | freebsd | netbsd | openbsd | darwin | solaris);
 
     const int bits = 8*sizeof(void*);
 
Index: configure.in
===================================================================
--- configure.in (revision 9146)
+++ configure.in (working copy)
@@ -279,7 +279,7 @@
 esac
 AC_MSG_RESULT($PIC_FLAGS)
 
-CPPFLAGS="$CPPFLAGS -DTIXML_USE_STL"
+CPPFLAGS="$CPPFLAGS -ansi -DTIXML_USE_STL"
 CXXFLAGS="$CXXFLAGS $PCH_FLAGS $PIC_FLAGS -fexceptions"
 AC_SUBST(codeblocks_PCH_FLAGS, "$PCH_FLAGS")
 

--- End code ---

This patch instructs gcc to undef all non-standard pre-processor macros.

Unfortunately we still have code, in our trunk, which relies on some non-standard macros. As a result this patch doesn't compile (build stops at depslib) at the moment. I'll explore it further when I have time.

MortenMacFly:

--- Quote from: Biplab on June 10, 2013, 02:21:41 pm ---This patch instructs gcc to undef all non-standard pre-processor macros.

--- End quote ---
Now that i am guided here, sorry for my ignorance in the other thread...

In fact I tend to agree with Thomas as it was a rather misleading and unexpected change for me in the first place.

Biplab:

--- Quote from: MortenMacFly on June 11, 2013, 07:40:18 am ---
--- Quote from: Biplab on June 10, 2013, 02:21:41 pm ---This patch instructs gcc to undef all non-standard pre-processor macros.

--- End quote ---
Now that i am guided here, sorry for my ignorance in the other thread...

In fact I tend to agree with Thomas as it was a rather misleading and unexpected change for me in the first place.

--- End quote ---

Would you care to explain why is it a "misleading" change?

MortenMacFly:

--- Quote from: Biplab on June 11, 2013, 08:23:32 am ---Would you care to explain why is it a "misleading" change?

--- End quote ---
...I did, but in the other thread before I found this one... :-[
http://forums.codeblocks.org/index.php/topic,18008.msg123115.html#msg123115

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version