Hi there,
o.k., I have now managed to create a custom root interpreter with at least
some ncurses functions (I did not try them all). As this thread has been
quite long, here is the complete procedure:
- I have created a main function (quoted below)
- I have created a LinkDef.h file for a number of ncurses functions
(quoted below). Please note that the 5.08 documentation refers to
#pragma link C function xyz;
to which rootcint reacts with the warning that “C++” should be
used instead of “C”.
- I have executed rootcint in the following way:
rootcint mydict.C -c -p /usr/include/ncurses.h LinkDef.h
- I have done the linking with the Makefile quoted below. Please note
that I’m not linking with all ROOT libraries (e.g. xrootd stuff is missing).
- I then could execute the unnamed script quoted below, which uses
the ncurses functions listed in LinkDef.h . I have attached a
screenshot of the output, which looks just as expected.
I still do not understand:
- Is there a way to include all functions., macros, etc. from a header
file without having to specifically mention each one of them ?
- When do I need to give arguments to the functions listed in
the #pragma statements ? E.g., printw has one fixed argument and
can, just like printf, accept a number of optional arguments. Not
mentioning any arguments in the #pragma statement seems to work
fine. However, apparently I do need to give arguments e.g. move(int,int),
if there is more than one function argument ?
In any case, thanks for all the help !
Best Regards,
Ruediger
/********************** main.C **********************/
//--------------------------------------------------
#include “TROOT.h”
#include “TRint.h”
int Error; //left undefined by Motif
extern void InitGui(); // initializer for GUI needed for interactive interface
VoidFuncPtr_t initfuncs[] = { InitGui, 0 };
// Initialize the ROOT system
TROOT root(“Rint”,“The ROOT Interactive Interface”, initfuncs);
int main(int argc, char **argv)
{
// Create interactive interface
TRint *theApp = new TRint(“ROOT example”, &argc, argv, NULL, 0);
// Run interactive interface
theApp->Run();
return(0);
}
//--------------------------------------------------
/********************** LinkDef.h **********************/
#ifdef CINT
#pragma link C++ function initscr;
#pragma link C++ function move(int,int);
#pragma link C++ function printw;
#pragma link C++ function refresh;
#pragma link C++ function getch;
#pragma link C++ function endwin;
#endif /* CINT */
/********************** Makefile **********************/
#---------------------------------------------------
CXXFLAGS = -g -I$(ROOTSYS)/include/root
LDFLAGS = -g
LD = g++
LIBS = -L/usr/X11R6/lib/ -L$(ROOTSYS)/lib/root -lXpm -lX11 -lm -lGpad -lGraf -lGraf3d -lHist -lMatrix -lRint -lCore -lCint -ldl -lc -lm -lz -lncurses
SRCS = main.C mydict.C
OBJS = main.o mydict.o
PROGRAM = myroot
all: $(PROGRAM)
(PROGRAM): (OBJS)
@echo "Linking (PROGRAM) ..."
@(LD) (LDFLAGS) (OBJS) (LIBS) -o (PROGRAM)
@echo “done”
clean:; @rm -f $(OBJS) core
mydict.C:
@echo “Generating dictionary …”
@rootcint mydict.C -c -p /usr/include/ncurses.h LinkDef.h
#---------------------------------------------------
/*************** unnamed ncurses script **********************/
{
initscr(); /* Start curses mode /
move(10,10); / Move cursor to position 10/10 /
printw(“Hello World !!!”); / Print Hello World /
refresh(); / Print it on to the real screen /
getch(); / Wait for user input /
endwin(); / End curses mode */
return 0;
}