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 Center および File ExchangeC Shared Library Integration についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by