Author Topic: warning: "nullptr" redefined when compile sdk\mozilla_chardet\src\nsSBCSGroupPro  (Read 15621 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6079
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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




If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6079
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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]
« Last Edit: January 08, 2014, 03:20:32 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
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?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7790
    • My Best Post
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.
« Last Edit: January 08, 2014, 07:25:08 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
No, you're not allowed, yet.
Also -std=c++11 is the correct option.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7790
    • My Best Post
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.
« Last Edit: January 08, 2014, 07:49:08 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline scarphin

  • Lives here!
  • ****
  • Posts: 640
Tim: I can confirm your patch removes the warning.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6079
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I commit the patch to rev9589, thanks for all your contribution.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.