I create a mex file that compiles and works properly in R2010b and up, versions I have at my work. But I need the same file be used in R2010a, since that's the version I have in my laptop. If I used in R2010 I have an error. I found the code need it to make it work. But every time I switch I have to comment and uncomment. Is there any way to find Matlab's version in the header? Let me give some code:
#include <stdlib.h> #include <vector> #include <queue> #include <limits> #include <utility> #include <map> #include <assert.h> #include <stdio.h> /* #ifdef _CHAR16T //for matlab 2010a #define CHAR16_T #endif */ #include "mex.h" #include "matrix.h" using namespace std;........code ............
The commented section is my fix. I want to find Matlab's version and put an if statement so it automatically applies my fix. I try this:
int i; int j; sscanf(version,'%d.%d %*s',&i, &j) #if i<=7 && j<11 #ifdef _CHAR16T //for matlab 2010a #define CHAR16_T #endif #endif
but it did not work since c++ did not find the "version" variable defined in matlab. Does somebody know how to do that? I really appreciate any help!
Best Answer