Author Topic: patch for -std=c++0x error  (Read 6467 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
patch for -std=c++0x error
« on: March 20, 2010, 05:15:11 am »
like this wx console demo:
Code
#include <wx/wx.h>
#include <wx/stdpaths.h>
#include <memory>

int main()
{
    std::shared_ptr<int> sp(new int(10));
    wxStandardPaths path;
    wxPuts(path.GetExecutablePath());
    return 0;
}
if use -std=c++0x, will have many error:
Quote
||=== wxCmd, src ===|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h||In constructor 'wxCharBuffer::wxCharBuffer(const char*)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h|127|error: 'strdup' was not declared in this scope|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h||In member function 'wxCharBuffer& wxCharBuffer::operator=(const char*)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h|127|error: 'strdup' was not declared in this scope|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h||In constructor 'wxWCharBuffer::wxWCharBuffer(const wchar_t*)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h|134|error: '_wcsdup' was not declared in this scope|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h||In member function 'wxWCharBuffer& wxWCharBuffer::operator=(const wchar_t*)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\buffer.h|134|error: '_wcsdup' was not declared in this scope|
D:\DengYC\LoveDEV\sdk\wx\include\wx\string.h||In function 'int Stricmp(const char*, const char*)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\string.h|141|error: 'strcasecmp' was not declared in this scope|
D:\DengYC\LoveDEV\sdk\wx\include\wx\list.h||In constructor 'wxListKey::wxListKey(const wxChar*)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\list.h|406|error: '_wcsdup' was not declared in this scope|
D:\DengYC\LoveDEV\sdk\wx\include\wx\list.h||In constructor 'wxListKey::wxListKey(const wxString&)':|
D:\DengYC\LoveDEV\sdk\wx\include\wx\list.h|408|error: '_wcsdup' was not declared in this scope|
||=== Build finished: 7 errors, 0 warnings ===|
but if change -std=c++0x to -std=gnu++0x, it can be fixed.
Code
Index: src/plugins/compilergcc/compilerMINGW.cpp
===================================================================
--- src/plugins/compilergcc/compilerMINGW.cpp (revision 6193)
+++ src/plugins/compilergcc/compilerMINGW.cpp (working copy)
@@ -115,7 +115,7 @@
     m_Options.AddOption(_("Stop compiling after first error"), _T("-Wfatal-errors"), category);
     m_Options.AddOption(_("Inhibit all warning messages"), _T("-w"), category);
     m_Options.AddOption(_("Have g++ follow the 1998 ISO C++ language standard"), _T("-std=c++98"), category);
-    m_Options.AddOption(_("Have g++ follow the coming C++0x ISO C++ language standard"), _T("-std=c++0x"), category);
+    m_Options.AddOption(_("Have g++ follow the coming C++0x ISO C++ language standard"), _T("-std=gnu++0x"), category);
     m_Options.AddOption(_("Enable warnings demanded by strict ISO C and ISO C++"), _T("-pedantic"), category);
     m_Options.AddOption(_("Treat as errors the warnings demanded by strict ISO C and ISO C++"), _T("-pedantic-errors"), category);
     m_Options.AddOption(_("Warn if main() is not conformant"), _T("-Wmain"), category);


[attachment deleted by admin]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: patch for -std=c++0x error
« Reply #1 on: March 20, 2010, 09:24:54 am »
Hello,

Thanks for the feedback.

You solution is however not acceptable. The flag we already support is to have :
Quote
Have g++ follow the coming C++0x ISO C++ language standard"

Your flag I think is not, and allows gnu extension to be added, and these extensions are not standard.

So replacing -std=c++0x to -std=gnu++0x is not an option.

We could however add an extra flag : activate gnu extensions to C++Ox standard, and that would then add the '-std=gnu++0x'.