Preprocessor command vs ACLiC

Hi,

I am trying to compile a macro which includes a ‘third-party’ header file. The header file requires some pre-processor commands that are usually set when invoking the compiler using the -D option (eg -D_SOMEOPTION)

Is there a way to set this when compiling with ACLiC?

thanks!
Peter

Hi,

you can “hack” it into ACLiC using TSystem::GetMakeSharedLib() and TSystem::SetMakeSharedLib(). You call Set… with the value returned by Get…, and replace “$IncludePath” by “$IncludePath -D_SOMEOPTION”.

Cheers, Axel.

Hi Axel,

I tried this but it didn’t work. I wrote a very simple test case with two files as follows:

myHeader.h:
#ifndef __SOME_COMMAND
#error SOME COMMAND MUST BE SET
#endif

myMacro.C
#include "myHeader.h"
void myMacro(){}

The root session is as follows:

root [0] gSystem->[b]GetMakeSharedLib/b
(const char* 0x1014049e8)“cd $BuildDir ; g++ -c $Opt -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -DR__HAVE_CONFIG -D_REENTRANT -pthread $IncludePath $SourceFiles ; MACOSX_DEPLOYMENT_TARGET=10.6 g++ $ObjectFiles -dynamiclib -single_module -undefined dynamic_lookup -O2 -m64 $DepLibs -o $SharedLib”

root [1] gSystem->SetMakeSharedLib(“cd $BuildDir ; g++ -c $Opt -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -DR__HAVE_CONFIG -D_REENTRANT -pthread $IncludePath -D__SOME_COMMAND $SourceFiles ; MACOSX_DEPLOYMENT_TARGET=10.6 g++ $ObjectFiles -dynamiclib -single_module -undefined dynamic_lookup -O2 -m64 $DepLibs -o $SharedLib”)

root [2] gSystem->[b]GetMakeSharedLib/b (const char* 0x10212c978)“cd $BuildDir ; g++ -c $Opt -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -DR__HAVE_CONFIG -D_REENTRANT -pthread $IncludePath -D__SOME_COMMAND $SourceFiles ; MACOSX_DEPLOYMENT_TARGET=10.6 g++ $ObjectFiles -dynamiclib -single_module -undefined dynamic_lookup -O2 -m64 $DepLibs -o $SharedLib”

root [3] .L myMacro.C++Info in TUnixSystem::ACLiC: creating shared library /Users/peter/code/testCode/./myMacro_C.soIn file included from /Users/peter/code/testCode/./myMacro.C:1, from /var/tmp//rootcint_4Lducu.h:3,
from /var/tmp/tmp.0.23w51G_cint.cxx:1:
/Users/peter/code/testCode/./myHeader.h:2:2: error: #error SOME COMMAND MUST BE SET
Error: external preprocessing failed. :0:

My root version is 5.27/01 on OSX 10.6.4 running gcc 4.2.1

thanks
Peter

Hi,

To complete add a macro declaration to ACLiC use:gSystem->AddIncludePath(" -D__SOME_COMMAND ");When using SetMakeSharedLib the declaration is only passed to the compiler and not to rootcint which with AddIncludePath it is passed on to both.

Cheers,
Philippe.