C++0X in mex
1 view (last 30 days)
Show older comments
I have a piece of code that I need to wrap in a mex file. The original code makes use of gnu++0x (or c++0x) standard by using "-std=gnu++0x" directive for g++. When I tried to add this directive to mex through
CFLAGS="\$CFLAGS -std=gnu++0x"
it does not recognize that I am requesting use of gnu++0x standard. However, if I use
CXXFLAGS="\$CXXFLAGS -std=gnu++0x"
then I get the following error
In file included from /home/agadre/Applications/matlab/R2010a/extern/include/mex.h:60, from hybrid_astar.cpp:4: /home/agadre/Applications/matlab/R2010a/extern/include/matrix.h:330: error: redeclaration of C++ built-in type ‘char16_t’
And of course if I comment out the piece of code that requires c++0x, then everything compiles just fine.
Is it even possible to compile mex files using c++0x? I would appreciate any inputs in this regard.
Thanks.
1 Comment
Walter Roberson
on 1 Sep 2015
Remember that GNU compilers consider it acceptable to lie about whether you are using a standard-compliant compiler or not. "We are not standard C and therefore we are not bound by the portion of the standard that says that some defines should only be active if you are using standard C". That was the point at which I lost faith in gcc and kin.
Answers (2)
Chirag Gupta
on 14 Jun 2011
This is basically because a new char16_t type conflicts with a type defined by MATLAB's header file in matrix.h.
I found plenty of hits on googling!
Try:
typedef wchar_t char16_t or
typedef CHAR16_T char16_t
0 Comments
R1tschy
on 1 Sep 2015
In Matlab 2009a you can define the macro CHAR16_T or _STDC_UTF_16_ than char16_t will not be defined. You may look at the definition of char16_t in matrix.h in your Matlab version.
0 Comments
See Also
Categories
Find more on Call C++ from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!