C++0X in mex

5 次查看(过去 30 天)
Aditya
Aditya 2011-6-14
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 个评论
Walter Roberson
Walter Roberson 2015-9-1
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.

请先登录,再进行评论。

回答(2 个)

Chirag Gupta
Chirag Gupta 2011-6-14
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

R1tschy
R1tschy 2015-9-1
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.

类别

Help CenterFile Exchange 中查找有关 Call C++ from MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by