RE:rootcint'ing a C header file

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Thu Feb 11 1999 - 14:20:26 MET


Damir,

rootcint takes everything as C++. In order to link C objects, there are 
basically 2 ways.

1) Use 'extern "C"' in your header file and pretend everything is C++.
mygr.h ------------------------------------------------
extern "C" {
struct ld_binheader {
   float elapsed_time;
   float datarate;  };

void ratio(float *c, float *a, float *b, int ncomplex);
}
-------------------------------------------------------
LinkDef.h----------------------------------------------
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes; 
#pragma link off all functions;

#pragma link C++ class ld_binheader;
#pragma link C++ function ratio;
#endif
-------------------------------------------------------
Please note that with rootcint, you must always use '#pragma link off' for
all globals, classes and functions  and  turn on the link for each indivisual
component in your header. '#pragma link C++ all' never works with rootcint. 


2) Use makecint instead of rootcint. If you turning on indivisual component is
too much painful  and  if you  do not use any of the ROOT related symbols in
the C header,  you can use makecint instead which comes with bare CINT. 
Makecint is a rootcint without ROOT staff. The object created by makecint can
be loaded into ROOT/CINT.

 $ makecint -mk Makefile -dl mygr.dll -h mygr.h -C mygr.c
 $ make -f Makefile

You will have mygr.dll. You may have some trouble , but I hope you can
work it out. You can load mygr.dll just like other sharedlibs.

Makecint can work with '#pragma link C all' if you do not include ROOT header.
In fact, you could omit LinkDef.h file because 'link all' is the default
behavior.

To get makecint, get cint5.13.tar.gz from http://root.cern.ch/Root/Cint.html
and build bare CINT. Documentation is in $CINTSYSDIR/doc/makecint.txt.

Masaharu Goto

-------------------------------------------------------------------------
Hi everybody,

I have a big C header file for which I would like to include all the
functions and structs in ROOT. I don't want to describe each function
and struct by one line in a LinkDef file because the number of functions
is going to change, as well as their names. Since there are one hundred
such functions...

So I tried to use the following linkdef :

LinkDef.h----------------------------------------------
#ifdef __CINT__

#pragma link off all globals;
#pragma link C++ all classes; // (tried also link C, same effect )
#pragma link C all functions;

#endif
-------------------------------------------------------

and the simplified header below, to show the problem :

mygr.h ------------------------------------------------
struct ld_binheader {
   float elapsed_time;
   float datarate;  };

void ratio(float *c, float *a, float *b, int ncomplex);
-------------------------------------------------------

if I do 

rootcint -f mygr_cint.cc -c mygr.h LinkDef.h

It tells me some Links are requested for ROOT specific classes : TClass,
TKey, TFile, etc... and some other std c++ : ostream, ...

well, if I try to do

g++ -g -fPIC -fno-rtti -fno-exceptions -I$ROOTSYS/include -c
mygr_cint.cc

I get a bunch of errors, mainly due to the fact that rootcint wants to
create a link with these ROOT classes. There is even a problem with
va_start.

I don't understand what I did wrong, this is all very simple.

If I do #pragma link off all classes; instead of #pragma link C++ all
classes;
I have an error which is " 'va_start' used in function with fixed args"
in mygr_cint.cc. Looking at this file, everything seems to indicate that
rootcint tries to create some links with some ROOT classes even if I
didn't ask anything.

Can anyone help me on this subject ?

Damir

-- 
=====================================================================
| Damir Buskulic                  | Universite de Savoie/LAPP       |
|                                 | Chemin de Bellevue, B.P. 110    |
| Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
| e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
=====================================================================
mailto:buskulic@lapp.in2p3.fr



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:29 MET