loadlibrary and preprocessor #define

조회 수: 9 (최근 30일)
Tomas Björklund
Tomas Björklund 2014년 5월 12일
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개)

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by