From: Danny S. <dan...@cl...> - 2002-12-22 04:06:36
|
----- Original Message ----- From: "Danny Smith" <dan...@cl...> To: <min...@li...> Sent: Sunday, 22 December 2002 01:59 Subject: Re: [MinGW-dvlpr] HEADSUP: GCC-3.2 and GCC-3.2.1 optimization causing link resolution errors. > This is a WAG. According to my reading of C++ standard, extern inline > means something different in C++ than does the GCC C extension extern > __inline__. It means inline the function _and_ also emit the function > with extern linkage. The GCC extension means inline the function if > possible, else use the extern symbol. > > That may be causing your problem. See if attached patch to ctype.h > helps. If it does than I will clean up rest inlines in headers in new > year. > Well, I don't know if it helps with your problem, but I think the extern inlines do need to be fixed in headers. Here is a testcase. Compied as C, the gcc "extern inline" extension is implemented and the linker complains about no foo. Compiled as C++, the C++ standard meaning of extern inline is implemented and foo is emitted. This would cause problems with multiple definitions in C++ if foo was in a header and another translation unit used foo in a similar way. /* compile this as "gcc -O2 inline.c" then compile as "gcc -O2 inline.C" */ #include <stdio.h> extern inline int foo(int a) { return a * 2;} int main () { int (* foofun)(int) = foo; int number = 2; /* Using the function's address means we can't inline foo. In C, the extern says to look elswhere for foo, In C++ the extern says to emit the function with extern linkage */ printf("2 * %d = %d\n", number, foofun(number)); return 0; } Question: Should we define __CTYPE_INLINE, __MATH_INLINE, etc in respective headers or just do a single __INLINE__ definition, conditional on __cplusplus, in _mingw.h and use it everywhere. My preference is the former, even though it means more work, because it is immediately visible to users reading the headers and also more flexible (say if we wanted to make __MATH_INLINE conditional on other defines). Danny > > > |