Wednesday, May 2, 2012

“char16_t” conflict when using Visual Studio 2010 and Matlab 2010 Mcc

The full error message is as followed:

1>c:\program files (x86)\matlab\r2008a\extern\include\matrix.h(345): error C2371: 'char16_t' : redefinition; different basic types
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'

I found two method to solve this problem from web:

1. Put all the Matlab related code into a namespace;

2. Insert a simple code like the follows:

   1:  #include "fminlbfgs.h"
   2:  #include "DemonEnergy.h"
   3:  //**********************************************
   4:  #ifdef _CHAR16T
   5:  #define CHAR16_T
   6:  #endif
   7:  //**********************************************
   8:  #include "Optimizer\libOptimizer.h"

In the above code segment, “#include "Optimizer\libOptimizer.h"” is the header file of MCC generated library.

No comments:

Post a Comment