Answer to ifstream and makecint question

Masaharu Goto (MXJ02154@niftyserve.or.jp)
Sun, 04 Jan 1998 23:22:00 +0900


Dear,

I received following questions from users before new year holiday.
I'm sorry for delay in reply.

It looks like both case work fine on my site. I need detail information
if the reporters still have problems.

-------------------------------------------------------------------
>Dear Masaharu Goto,
>
>I'm trying to use makecint to add a large graphics library to CINT. Some
>
>of the functions have as many as 12 parameters. When some of the
>functions are called, the parameters are all zeros. I found this by
>looking
>at the program with the debugger. The environment is MSVC 4.0 under
>NT 4.0. Can you tell me why some of the functions don't get the correct
>parameter values?
>
>Here is one of the functions:
>
>extern Lightsource * spotlight_create (float x, float y, float z,
>float to_x, float to_y, float to_z, float fov, float red, float
>grn, float blu, int type, bool shadows);
>
>Thanks,
>
>Ron King

I tried this

/* ron1.h ************************************************************/
typedef int Lightsource ;
extern Lightsource * spotlight_create (float x, float y, float z,
float to_x, float to_y, float to_z, float fov, float red, float
grn, float blu, int type, bool shadows);

/* ron1.C ************************************************************/
#include <iostream.h>
#include "ron1.h"

Lightsource * spotlight_create (float x, float y, float z,
float to_x, float to_y, float to_z, float fov, float red, float
grn, float blu, int type, bool shadows) {
cout << "x = " << x << endl; ;
cout << "y = " << y << endl; ;
cout << "z = " << z << endl; ;
cout << "to_x = " << to_x << endl; ;
cout << "to_y = " << to_y << endl; ;
cout << "to_z = " << to_z << endl; ;
cout << "fov = " << fov << endl; ;
cout << "red = " << red << endl; ;
cout << "grn = " << grn << endl; ;
cout << "blu = " << blu << endl; ;
cout << "type = " << type << endl; ;
cout << "shadows = " << shadows << endl; ;
return ((int*)NULL);
}

/* COMMAND LINE on Linux */

$ makecint -dl ron1.dll -mk makeron1 -H ron1.h -C++ ron1.C
$ make -f makeron1
$ cint ron1.dll
cint> p spotlight_create(1,2,3,1,2,3,1,1,2,3,1,0)
x = 1
y = 2
.
.

So, it is working as it should. Will you debug into G__cpp_ron1.C file
for more detail? Or just looking into that file may give you some idea.

-------------------------------------------------------------------
>Hi
>
> The little function given below is supposed to
> read some file names from a list (and later chain the
> corresponding files in root)
> The reading of the list works fine if compiled
> outside root but when loaded in root and
> run from the intepreter root crashes !
>
> A bug or just my C++/root ignorance ?
>
> Here the function :
>
>
>#include <fstream.h>
>#include <iostream.h>
>
>void FileChain(const char *filename=0)
>{
>
> char Buf[256];
> char c;
>
> ifstream List(filename);
> if (!List){ cerr << " cannot open " << filename ; }
> else {
> while(List.get(Buf,256,'\n'))
> { cout << Buf << '\n' ;
> if (List.get(c) && c!='\n') { cout << "error : line truncated" ;}
> }
> }
>}

I tried above program on Linux and it worked fine on interpreter. Will you
tell me your computer platform and version of the interpreter?

Masaharu Goto