Re: Two class definitions in different translation units

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2014.10.28 at 14:16 +0400, Alex Markin wrote:
> Thanks for the answer.
> 
> > The compiler cannot warn, it has no way to know when compiling t1.cpp
> > that there's a different definition in t2.cpp, and vice versa.
> 
> And what about lto (now it does not warn)?

gcc-5 warns:

 % g++ -flto -Wodr *cpp -O1 && ./a.out
t1.cpp:4:7: warning: type ‘struct A’ violates one definition rule [-Wodr]
 class A
       ^
t2.cpp:5:7: note: a different type is defined in another translation unit
 class A
       ^
t1.cpp:8:9: note: the first difference of corresponding definitions is field ‘a’
     int a;
         ^
t2.cpp:9:10: note: a field with different name is defined in another translation unit
      int b;
          ^

-- 
Markus




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux