Hi Hugo, > > > > Thanks Axel. It is stranger yet: > > 1. mutrec is defined in aa.cpp > > 2. It is used as extern in mc.cpp, grafrs.cpp and setfile.cpp > > 3. But g++-4.5 only finds undefined referenes in mc.cpp and grafrs.cpp, > > *not* in setfile.cpp > > 4. Yet the extern for mutrec is defined in all three the same way. > > 5. And previous compilers have found no errors. > > 6. The whole bunch is linked together via aa.pro that is used in > > 'qmake-qt4 -o Makefile aa.pro' to create a makefile for make. > Some updates from my checks: > a) I can't compile the code on amd64: in tranrs.cpp, lines 1789 and 1810 > you convert "double *" to "int". However, on amd64 "double *" is of > size 8 bytes, "int" is only 4 bytes ==> You loose precision and get > quite unpredictable results. In addition, g++ from squeeze and wheezy > (4.4 and 4.5) do NOT compile it. Chaning "int" to "long", it works > correctly (maybe the "correct" type would be std::ptrdiff_t?) > > b) The linker error: There is a difference between mc.cpp grafrs.cpp AND > setfile.cpp: > - setfile: you have "extern mutrc" OUTSIDE of all functions > - mc and grafrs: the extern mutrc appears IN a function (drwts and > weights) > Maybe that's the critical point? I succeeded to create a testcase: a.cc: extern struct {int cnt;} mutrec; int main(){ mutrec.cnt = 2; }
b.cc: struct{ int cnt; } mutrec = { 0}; This compiles fine with g++-4.4, but not with g++-4.5 (just try "g++-4.4 a.cc b.cc" and "g++-4.5 a.cc b.cc") g++-4.5 states: /tmp/cc06Uy69.o: In function `f()': a.cc:(.text+0x6): undefined reference to `mutrec' collect2: ld returned 1 exit status However, both versions mention the problem: a.cc:2:28: warning: non-local variable ‘f()::<anonymous struct> mutrec’ uses anonymous type b.cc:1:23: warning: non-local variable ‘<anonymous struct> mutrec’ uses anonymous type So, it compiles & links fine if you give those structures a name (e.g. call them "A"): a.cc: extern struct A {int cnt;} mutrec; int main(){ mutrec.cnt = 2; } b.cc: struct A { int cnt; } mutrec = { 0}; Then, both g++-4.4 and g++-4.5 succeed to link the code. However, I'm not sure what the C++-standard says to this problem -- should it work with anonymous structures or not? HTH, Axel -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110313140515.GQ11958@axel