Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: ollydbg on December 25, 2013, 03:36:37 am

Title: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: ollydbg on December 25, 2013, 03:36:37 am
Code
-------------- Build: sdk in Code::Blocks wx2.8.x (compiler: GNU GCC Compiler)---------------

[ 50.0%] g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -Winvalid-pch -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE -Woverloaded-virtual -DEXPORT_LIB -DEXPORT_EVENTS -DWXMAKINGDLL_SCI -iquote.objs\include -I.objs\include -I. -IE:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\include -IE:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\mswu -Isdk\wxscintilla\include -Isdk\wxpropgrid\include -Iinclude\tinyxml -Iinclude -Iinclude\tinyxml -Iinclude\scripting\bindings -Iinclude\scripting\include -Iinclude\scripting\sqplus -Iinclude\mozilla_chardet -Iinclude\mozilla_chardet\mfbt -Iinclude\mozilla_chardet\nsprpub\pr\include -Iinclude\mozilla_chardet\xpcom -Iinclude\mozilla_chardet\xpcom\base -Iinclude\mozilla_chardet\xpcom\glue -Isdk\wxpropgrid\include -c sdk\mozilla_chardet\src\nsSBCSGroupProber.cpp -o .objs\sdk\mozilla_chardet\src\nsSBCSGroupProber.o
In file included from include/sdk_events.h:12:0,
                 from include/manager.h:21,
                 from include/configmanager.h:17,
                 from sdk\mozilla_chardet\src\nsSBCSGroupProber.cpp:10:
include/prep.h:41:0: warning: "nullptr" redefined [enabled by default]
In file included from sdk\mozilla_chardet\src\nsSBCSGroupProber.cpp:8:0:
include\mozilla_chardet\mfbt/mozilla/NullPtr.h:40:0: note: this is the location of the previous definition


When look at this code in nsSBCSGroupProber.cpp

Code
#include <stdio.h>
#include "prmem.h"
#include "mozilla/NullPtr.h"

#include "configmanager.h"

#include "nsSBCharSetProber.h"
#include "nsSBCSGroupProber.h"

In mozilla/NullPtr.h, it has:
Code
#ifndef MOZ_HAVE_CXX11_NULLPTR
#  if defined(__GNUC__)
#    define nullptr __null   //******************** line 40
#  elif defined(_WIN64)
#    define nullptr 0LL
#  else
#    define nullptr 0L
#  endif
#endif




Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: MortenMacFly on December 25, 2013, 10:51:17 am
I wouldn't touch that now if not absolutely needed. I've an update for the Mozilla component after 13/12. hen we'll see if this is still an issue...
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: ollydbg on January 08, 2014, 03:17:16 pm
I wouldn't touch that now if not absolutely needed. I've an update for the Mozilla component after 13/12. hen we'll see if this is still an issue...

It's still an issue. (I build the latest svn head rev 9544, against wx30 C::B project, MinGW-Build GCC 4.7.3dw2)

Also, some other warnings like:
Code
[ 29.8%] g++.exe -Wall -g -pipe -mthreads -fmessage-length=0 -fexceptions -DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL -DcbDEBUG -DNOPCH -DwxUSE_UNICODE -Woverloaded-virtual -DEXPORT_LIB -DEXPORT_EVENTS -DWXMAKINGDLL_SCI -IE:\code\wx\wxWidgets-3.0.0\include -IE:\code\wx\wxWidgets-3.0.0\lib\gcc_dll\mswu -Isdk\wxscintilla\include -Iinclude\tinyxml -Iinclude -Iinclude\tinyxml -Iinclude\scripting\bindings -Iinclude\scripting\include -Iinclude\scripting\sqplus -Iinclude\mozilla_chardet -Iinclude\mozilla_chardet\mfbt -Iinclude\mozilla_chardet\nsprpub\pr\include -Iinclude\mozilla_chardet\xpcom -Iinclude\mozilla_chardet\xpcom\base -Iinclude\mozilla_chardet\xpcom\glue -c sdk\editorbase.cpp -o .objs30\sdk\editorbase.o
In file included from include/cbauibook.h:10:0,
                 from sdk\editorbase.cpp:26:
E:\code\wx\wxWidgets-3.0.0\include/wx/aui/auibook.h:349:18: warning: 'virtual bool wxAuiNotebook::AddPage(wxWindow*, const wxString&, bool, int)' was hidden [-Woverloaded-virtual]
In file included from sdk\editorbase.cpp:26:0:
include/cbauibook.h:132:14: warning:   by 'bool cbAuiNotebook::AddPage(wxWindow*, const wxString&, bool, const wxBitmap&)' [-Woverloaded-virtual]
In file included from include/cbauibook.h:10:0,
                 from sdk\editorbase.cpp:26:
E:\code\wx\wxWidgets-3.0.0\include/wx/aui/auibook.h:352:18: warning: 'virtual bool wxAuiNotebook::InsertPage(size_t, wxWindow*, const wxString&, bool, int)' was hidden [-Woverloaded-virtual]
In file included from sdk\editorbase.cpp:26:0:
include/cbauibook.h:147:14: warning:   by 'bool cbAuiNotebook::InsertPage(size_t, wxWindow*, const wxString&, bool, const wxBitmap&)' [-Woverloaded-virtual]
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: MortenMacFly on January 08, 2014, 06:03:38 pm
OK, then we probably should sure that MOZ_HAVE_CXX11_NULLPTR is defined:

Either by locking what leads to the fact it is not and adjusting it
...or by simply defining it. :-)

Thats the relvant part:
Code
#elif defined(__GNUC__)
#  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
#    if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
#      define MOZ_HAVE_CXX11_NULLPTR
#    endif
#  endif
#elif defined(_MSC_VER) && _MSC_VER >= 1600

...one condition is false. The question is: Which one?
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: stahta01 on January 08, 2014, 07:16:56 pm
This line is likely false under Windows cbp compiles.

Code
if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L

Are we allowed to set a -std=gnu++11 to fix the problem under windows.
I ask because I read that we were NOT going to a higher C++ Standard under Linux.

Note: Using "-std=gnu++11" results in a even more annoying warning.

Tim S.
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: oBFusCATed on January 08, 2014, 07:35:36 pm
No, you're not allowed, yet.
Also -std=c++11 is the correct option.
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: stahta01 on January 08, 2014, 07:47:29 pm
No, you're not allowed, yet.
Also -std=c++11 is the correct option.

IIRC, CB Will NOT compile (on windows using MinGW TDM) with -std=c++11 because that hides too many things like _popen last time I tried about 4 months ago.

Possible patch; but, I am coughing and sneezing too much to test it.
Code
Index: src/include/mozilla_chardet/mfbt/mozilla/NullPtr.h
===================================================================
--- src/include/mozilla_chardet/mfbt/mozilla/NullPtr.h (revision 9544)
+++ src/include/mozilla_chardet/mfbt/mozilla/NullPtr.h (working copy)
@@ -12,6 +12,9 @@
 #ifndef mozilla_NullPtr_h
 #define mozilla_NullPtr_h
 
+// C::B patch: to fix multiple defines of nullptr
+#include "prep.h"  // C::B Header that defines nullptr
+
 #include "mozilla/Compiler.h"
 
 #if defined(__clang__)
Index: src/include/prep.h
===================================================================
--- src/include/prep.h (revision 9544)
+++ src/include/prep.h (working copy)
@@ -39,6 +39,7 @@
         const nullptr_t& operator=(const nullptr_t&);
     } nullptr_;
     #define nullptr nullptr_
+    #define MOZ_HAVE_CXX11_NULLPTR  // prevents mozilla/NullPtr.h from defining nullptr.
 
     template<typename T> inline bool operator==(const nullptr_t& lhs, T const& rhs) { return  lhs.equals(rhs); }
     template<typename T> inline bool operator==(T const& lhs, const nullptr_t& rhs) { return  rhs.equals(lhs); }

Tim S.
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: scarphin on January 17, 2014, 12:14:10 am
Tim: I can confirm your patch removes the warning.
Title: Re: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro
Post by: ollydbg on January 20, 2014, 08:36:52 am
I commit the patch to rev9589, thanks for all your contribution.