An interesting ACLiC message

Hi,

I made the following simple files (TMyClass.h):

[code]#ifndef ROOT_TMyClass
#define ROOT_TMyClass

#ifndef ROOT_TObject
#include “TObject.h”
#endif

class TMyClass : public TObject {
// TMyClass();
// virtual ~TMyClass();
ClassDef(TMyClass,2)
};
#endif[/code]
and TMyClass.c

[code]#include “TMyClass.h”

ClassImp(TMyClass)

TMyClass::TMyClass(): TObject()
{
}
TMyClass::~TMyClass()
{
}[/code]

If I uncomment the two lines in the .h file, i.e. I have both contructor and destructor I receive the message

[quote]root [13] .L TMyClass.c+
Info in TWinNTSystem::ACLiC: creating shared library C:\veghj\projects\root\ewa\TMyClass_c.dll
23596100_cint.cxx
s1pc_1n.cxx
Creating library C:\veghj\projects\root\ewa\TMyClass_c.lib and object C:\veghj\projects\root\ewa\TMyClass_c.exp[/quote]
i.e. this simple case compiles OK. If I try to compile the files as shown above (i.e. I do have neither constructor nor destructor) I receive

[quote]root [12] .L TMyClass.c+
Info in : modified script has already been compiled and loaded
Info in : it will be regenerated and reloaded!
Info in TWinNTSystem::ACLiC: creating shared library C:\veghj\projects\root\ewa\TMyClass_c.dll
22376120_cint.cxx
s1pc_1i.cxx
C:\veghj\projects\root\ewa\TMyClass.c(5) : error C2084: function ‘__thiscall TMyClass::TMyClass(void)’ already has a body
C:\veghj\projects\root\ewa\TMyClass.c(10) : error C2084: function ‘__thiscall TMyClass::~TMyClass(void)’ already has a body
C:\veghj\projects\root\ewa\s1pc_1i.cxx(130) : error C2264: ‘TMyClass::TMyClass’ : error in function definition or declaration; function not called
C:\veghj\projects\root\ewa\s1pc_1i.cxx(130) : error C2264: ‘TMyClass::TMyClass’ : error in function definition or declaration; function not called
C:\veghj\projects\root\ewa\s1pc_1i.cxx(276) : error C2264: ‘TMyClass::TMyClass’ : error in function definition or declaration; function not called
Error in : Compilation failed![/quote]
i.e. interestingly enough, the missing members are reported as duplicate rather than missing. A rather misleading message!

Also interesting that if I remove the function definitions, too, I receive

[quote]root [14] .L TMyClass.c+
Info in : modified script has already been compiled and loaded
Info in : it will be regenerated and reloaded!
Info in TWinNTSystem::ACLiC: creating shared library C:\veghj\projects\root\ewa\TMyClass_c.dll
23912100_cint.cxx
s1pc_1s.cxx
Creating library C:\veghj\projects\root\ewa\TMyClass_c.lib and object C:\veghj\projects\root\ewa\TMyClass_c.exp
s1pc_1s.obj : error LNK2001: unresolved external symbol “private: virtual __thiscall TMyClass::~TMyClass(void)” (??1TMyClass@@EAE@XZ)
C:\veghj\projects\root\ewa\TMyClass_c.dll : fatal error LNK1120: 1 unresolved externals
Error in : Compilation failed![/quote]
i.e. only the missing destructor is noticed, the constructor not.

I also think it is not of much use to report the line number of the temporary file where the error detected, if the file itself is deleted.

Janos

Please don’t post the same question multiple times. Thread http://root.cern.ch/phpBB2/viewtopic.php?p=7707 is where your answers will be.
Axel.

Hi,

[quote=“Axel”]Please don’t post the same question multiple times. Thread http://root.cern.ch/phpBB2/viewtopic.php?p=7707 is where your answers will be.
Axel.[/quote]
I do not think it it the same question.
At the place pointed by you, I am asking why the preprocessor interferes with a macro expansion, here I am asking why the lack of constructor and destructor is diagnosed as if they were present in duplicate, and why
no error is reported if both the declaration and definition of the constructor are missing.

Janos

Hi Janos,
sorry about that; you’re obviously right.

[quote=“jvegh”]If I try to compile the files as shown above (i.e. I do have neither constructor nor destructor) I receive

[quote]root [12] .L TMyClass.c+
C:\veghj\projects\root\ewa\TMyClass.c(5) : error C2084: function ‘__thiscall TMyClass::TMyClass(void)’ already has a body
C:\veghj\projects\root\ewa\TMyClass.c(10) : error C2084: function ‘__thiscall TMyClass::~TMyClass(void)’ already has a body

Error in : Compilation failed![/quote]
i.e. interestingly enough, the missing members are reported as duplicate rather than missing. A rather misleading message![/quote]
You left the constructor and destructor implementations in there, while removing the declarations. Not good, as the compiler will generate a number of default methods if they don’t exist (see the C++ standard). These clash with your implementations. Also, note that these error messages are issued by compiler (cl), so you should complain with Microsoft if you don’t like them…

[quote=“jvegh”]Also interesting that if I remove the function definitions, too, I receive

[quote]root [14] .L TMyClass.c+

s1pc_1s.obj : error LNK2001: unresolved external symbol “private: virtual __thiscall TMyClass::~TMyClass(void)” (??1TMyClass@@EAE@XZ)
C:\veghj\projects\root\ewa\TMyClass_c.dll : fatal error LNK1120: 1 unresolved externals
Error in : Compilation failed![/quote]
i.e. only the missing destructor is noticed, the constructor not.[/quote]That’s the usual behavior of the Microsoft linker. Again - complain with them, please.

[quote=“jvegh”]I also think it is not of much use to report the line number of the temporary file where the error detected, if the file itself is deleted.[/quote] That’s right, but I don’t know of any compiler flag that tells cl not to issue line numbers.

Summary: you have tested the error handling of Microsoft’s compiler.
Axel.