Re: use of '#define FOO' in macro

From: OKUMURA, Akira <oxon_at_icrr.u-tokyo.ac.jp>
Date: Fri, 1 Jun 2007 20:21:10 -1000


Hello Axel,

> extern const bool b1;
> #pragma link C++ global b1;

I tried your hack but it did not compile.

$ make
rootcint -f FITS.cxx -c -I/usr/local/include FITSfunctions.h FITSLinkDef.h
Syntax error /usr/local/include/CCfits/FITSUtil.h:322: Warning: Error occurred during reading source files Warning: Error occurred during dictionary source generation !!!Removing FITS.cxx FITS.h !!!
Error: rootcint: error loading headers... make: *** [FITS.cxx] Error 1

I attache four files.

- Makefile
- FITSfunctions.h
- FITSLinkDef.h
- rootfits.cxx

Would you check the files? There may be my mistakes. However - CFITSIO http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html - CCFITS http://heasarc.gsfc.nasa.gov/fitsio/CCfits/ are needed if you compile my code.

gcc version 4.0.1 (Apple Computer, Inc. build 5367) cint revision : 5.16.18, February 9, 2007 by M.Goto root Version 5.15/02 13 February 2007 OS X 10.4.9 PPC Sincerely

OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
Institute for Cosmic Ray Research, University of Tokyo 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan Phone/Fax : +81 4-7136-3153
Skype : okumura.akira

On 2007/06/01, at 2:53, Axel Naumann wrote:

> Hi,
>
> sorry for the slow reply! -p invokes the external preprocessor - all
> preprocessor macros will already be expanded when CINT sees your code.
> It will thus not be able to use it.
>
> Instead, do not use -p, and instead use the following hack. Put in
> your
> Linkdef.h:
> extern const bool b1;
> #pragma link C++ global b1;
>
> This way, CINT will know that b1 is a variable. And you don't have to
> change the CCfits header files.
>
> Cheers, Axel.
>
> OKUMURA, Akira wrote:
>> Hello ROOTers,
>>
>> '-p' option given to rootcint seems to prevent my code from using
>> global
>> macro. I wrote simple test codes which had some '#define'
>> constants and
>> compiled them using '-p' option of rootcint. I could not access such
>> constants from interpreter but I could do it if I delete '-p'.
>>
>> However in my original code which was linked to CCFITS needs '-p'
>> because a declaration of bool in its header cannot be handled by CINT
>> correctly.
>> (see http://root.cern.ch/root/roottalk/roottalk06/1562.html)
>>
>> Any suggestion?
>>
>> Sincerely
>>
>> OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
>> Institute for Cosmic Ray Research, University of Tokyo
>> 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
>> Phone/Fax : +81 4-7136-3153
>> Skype : okumura.akira
>>
>> On 2007/05/23, at 5:00, OKUMURA, Akira wrote:
>>
>>> Hello ROOTers,
>>>
>>> I found an old post in roottalk.
>>> http://root.cern.ch/root/roottalk/roottalk98/2493.html
>>> I tried this but I still get 'Error: Symbol SHORT_IMG is ...'.
>>>
>>> I added
>>> #defined SHORT_IMG 16
>>> in FITSfunction.h, and
>>> #pragma link C++ global SHORT_IMG;
>>> in FITSLinkDef.h .
>>>
>>> These two headers correspond to CERNfunction.h and CERNLinkDef.h
>>> (see http://root.cern.ch/root/HowtoCERNLIB.html)
>>>
>>> Sincerely
>>>
>>> OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
>>> Institute for Cosmic Ray Research, University of Tokyo
>>> 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
>>> Phone/Fax : +81 4-7136-3153
>>> Skype : okumura.akira
>>>
>>> On 2007/05/22, at 17:44, OKUMURA, Akira wrote:
>>>
>>>> Hello ROOTers
>>>>
>>>> I compiled my original ROOT according to the web page
>>>> http://root.cern.ch/root/HowtoCERNLIB.html
>>>> It was compiled with the library CCfits (C++ FITS library).
>>>>
>>>> One of its headers has some #define lines such as
>>>> #define BYTE_IMG 8
>>>> #define SHORT_IMG 16
>>>> #define LONG_IMG 32
>>>>
>>>> If I use these constants in my macro, I get an error.
>>>> root [0] .x test.C
>>>> Error: Symbol SHORT_IMG is not defined in current scope
>>>> cookbook.C:114:
>>>> *** Interpreter error recovered ***
>>>>
>>>> but
>>>> root [0] .x test.C+
>>>> runs as I expected.
>>>>
>>>> Is it possible to use #define constants of the library in my macro
>>>> without compiling? Is there any solution?
>>>>
>>>> Sincerely
>>>>
>>>> OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
>>>> Institute for Cosmic Ray Research, University of Tokyo
>>>> 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
>>>> Phone/Fax : +81 4-7136-3153
>>>> Skype : okumura.akira
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Received on Sat Jun 02 2007 - 08:42:25 CEST

This archive was generated by hypermail 2.2.0 : Sat Jun 02 2007 - 17:50:01 CEST