loadlibrary and preprocessor #define
9 次查看(过去 30 天)
显示 更早的评论
Hi!
My basic problem is that I cannot get loadlibrary to define a symbol to be set when parsing an .h-file. Is there any way to set such a define from Matlab that I have missed?
As a workaround I tried to make loadlibrary use a special .h-file that in itself set the defines like this and in turn includes the real .h-file:
// matlabIncludeFile.h
#define MATLAB_ONLY
#include "realIncludeFile.h"
// realIncludeFile.h
#ifdef MATLAB_ONLY
...
//What I want matlab to see
...
#else
...
//What I want all other compilers to see
...
#endif
But here it seems like a bug because realIncludeFile.h is parsed as if MATLAB_ONLY is not defined. If I move #define MATLAB_ONLY from matlabIncludeFile.h to realIncludeFile.h it works but that of course defeats my goal of having a specific define set when parsing via Matlab.
I have other options but they don't appeal to me for various reasons such as:
- Different include directories for matlab and not-matlab parsing
- A #ifndef and compiler constant in commandline of all other compilers.
Any suggestions to solve my original problem? For example, does Matlab set up a specfic predefined macros such as GCC's _GNUC_?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 C Shared Library Integration 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!