I am trying to compile my new class. If the source contains
#if !defined(__CINT__)
// Define the class for the cint dictionary
ClassDef(TDocFile,1);
#endif
I receive
[quote]root [1] .x TDocFileTest.C
e_C.dll TWinNTSystem::ACLiC: creating shared library F:\root\tutorials\TDocFil
s1hc.1_cint.cxx
s1hc.3_cint.cxx
s1hc.5_cint.cxx
s1hc.7_cint.cxx
Error in : TDocFile inherits from TObject but does not have its own Cl
assDef
sv0_4.cxx
F:\root\tutorials\sv0_4.h(7) : fatal error C1083: Cannot open include file: ‘std
def.h’: No such file or directory
Error in : Compilation failed!
Error: Symbol TDocFile is not defined in current scope FILE:F:\root\tutorials\T
DocFileTest.C LINE:8
Error: Symbol TDocFile is not defined in current scope FILE:F:\root\tutorials\T
DocFileTest.C LINE:8
Error: type TDocFile not defined FILE:F:\root\tutorials\TDocFileTest.C LINE:8
*** Interpreter error recovered ***[/quote]
If the source contains
//#if !defined(__CINT__)
// Define the class for the cint dictionary
ClassDef(TDocFile,1);
//#endif
then the reply is
s204.7_cint.cxx
Warning: Error occured during reading source files
Warning: Error occured during dictionary source generation
!!!Removing F:\root\tutorials\sv0_8.cxx F:\root\tutorials\sv0_8.h !!!
Error: rootcint: error loading headers…
Error in : Dictionary generation failed!
Error: Symbol TDocFile is not defined in current scope FILE:F:\root\tutorials\T
DocFileTest.C LINE:8
Error: Symbol TDocFile is not defined in current scope FILE:F:\root\tutorials\T
DocFileTest.C LINE:8
Error: type TDocFile not defined FILE:F:\root\tutorials\TDocFileTest.C LINE:8
*** Interpreter error recovered ***[/quote]
The Qt port case is more simple:
[quote]root [0] .x TDocFileTest.C
Info in TWinNTSystem::ACLiC: creating shared library F:\ROOT\tutorials\TDocFil
e_C.dll
‘rootcint’ is not recognized as an internal or external command,
operable program or batch file.
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity
TDocFile.C
F:\ROOT\tutorials\TDocFile.C(0) : fatal error C1083: Cannot open include file: ’
w32pragma.h’: No such file or directory
Error: Symbol TDocFile is not defined in current scope FILE:F:\ROOT\tutorials\T
DocFileTest.C LINE:8
Error: Symbol TDocFile is not defined in current scope FILE:F:\ROOT\tutorials\T
DocFileTest.C LINE:8
Error: type TDocFile not defined FILE:F:\ROOT\tutorials\TDocFileTest.C LINE:8
Warning: Automatic variable TDocFileDF is allocated FILE:F:\ROOT\tutorials\TDoc
FileTest.C LINE:8
Error: Undeclared variable TDocFileDF FILE:F:\ROOT\tutorials\TDocFileTest.C LIN
E:8
*** Interpreter error recovered ***[/quote]
independently if I use ClassDef or not.
you are right: it is a code under debugging. I simply wanted to avoid typing the same lines many times, so I put it in another test script.
And, I cannot reach the phase when I can debug and test my class:
when compiling my class it aborts at the ClassDef line.
What you write:
it does mean that I can only use a fully debugged class and the way I intended to use for debugging (to call a script from another script) cannot work?
or
it does mean that the compiler writes out a consequence error first (and only that) rather than the primary error because there are some other (C++) errors, which I believed that the compiler has not seen yet?
It is very kind of you that you started to discover my bad coding, but it was not my intention to load you with such activity. I just need help in finding out why the compiler does not like my code. I was simply lazy to simplify the code, because I guessed you will not continue reading after reaching the ClassDef line. Sorry for it.
Now I simplifyied my program, like this:
[code]#include “TObject.h”
class TDocFile : public TObject
{
public:
TDocFile(void);
~TDocFile(void);
// ClassDef(TDocFile,1);
};
and the result with root is, depending on if ClassDef if commented out or not:
[quote]root [6] .x TTest.C++
Info in TWinNTSystem::ACLiC: creating shared library F:\root\tutorials\TTest_C.dll
s20c.1_cint.cxx
s20c.3_cint.cxx
s20c.5_cint.cxx
s20c.7_cint.cxx
s12k_o.cxx
F:\root\tutorials\s12k_o.h(7) : fatal error C1083: Cannot open include file: ‘stddef.h’: No such file or directory
Error in : Compilation failed!
Error: Function TTest() is not defined in current scope FILE: LINE:0
Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***
root [7] .x TTest.C++
Info in TWinNTSystem::ACLiC: creating shared library F:\root\tutorials\TTest_C.dll
s1io.1_cint.cxx
s1io.3_cint.cxx
s1io.5_cint.cxx
s1io.7_cint.cxx
Error in : TDocFile inherits from TObject but does not have its own ClassDef
s12k_s.cxx
F:\root\tutorials\s12k_s.h(7) : fatal error C1083: Cannot open include file: ‘stddef.h’: No such file or directory
Error in : Compilation failed!
Error: Function TTest() is not defined in current scope FILE: LINE:0
Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***[/quote]
so I believe my experiences have no relation with the fact that the submitted sample still contains C++ errors.
If a class inherit from TObject (like your TDocFile), it has to have a ClassDef. The ClassDef macro has to be seen by both the compiler and cint. So do not put
[quote]#if !defined(CINT)
// Define the class for the cint dictionary
ClassDef(TDocFile,1); #endif[/quote]
If your class does not inherit from TObject, the ClassDef is optional.
Rename your fuile TDocFileTest.C into TDocFileTest.cpp (windows is case insensitive and cl thinks your passing a c file (as opposed to a c++ file).
Your environment is not set properly (%ROOTSYS%/bin missing on %PATH%)