Re:include issue

=?ISO-2022-JP?B?GyRCOGVGIyEhQDU8IxsoQg==?= (MXJ02154@niftyserve.or.jp)
Sat, 13 Sep 1997 21:42:00 +0900


Andrew,
INET:andrews@physicx.berkeley.edu

Rene asks me to answer this.

Your example is a legal C/C++ code, however, please do not use #include
in this way. CINT handles #include files a little smarter than compilers.
But it can't handle some minor case usage like this.
Please don't use #include with in a function for CINT.

> // START "testinclude"//
>Char_t teststring[80];
>Int_t testint;
>sprintf(teststring,"This is my test string.");
>testint = 50;
>// END "testinclude" //
>And here is a program that tries to include it:
>#pragma includepath [my path goes here]
>testfun() {
> #include <testinclude>
> printf("The integer will print: %d\n",testint);
> printf("But the string will not: %s",teststring);
>}

I modified above files. Use macro with a dummy argument. CINT can
handle this type of macro. Include the header outside of the function
and use INITTEST(0); in the function.

======header====================================
#define INITTEST(dmy) \
Char_t teststring[80]; \
Int_t testint; \
sprintf(teststring,"This is my test string."); \
testint = 50

======source====================================
And here is a program that tries to include it:
#pragma includepath [my path goes here]
#include <testinclude>
testfun() {
INITTEST(0);
printf("The integer will print: %d\n",testint);
printf("But the string will not: %s",teststring);
}

Masaharu Goto