From: Greg C. <chi...@co...> - 2006-04-04 14:49:20
|
On 2006-4-4 4:41 UTC, Brian Dessent wrote: > Greg Chicares wrote: > >>I asked one of the wx developers to consider removing their >>dll[im|ex]port macro. He replied that we can't know for sure >>whether the compiler actually inlines that function, and, if >>it doesn't, then we really do need dllimport to use it. > > This doesn't make any sense. According to the docs[*], unless you > explicitly use "static inline" the compiler will always assume that the > function may be called from some other translation unit, and it will > provide a function body. So even if the compiler ignored the "inline", > any translation unit that included dnd.h would have a copy of the > function anyway, and no need to import it. The "dllimport" seems like a > no-op to me since by providing a function declaration in the header you > ensure that any file that includes that header will have a local copy of > the function.... > > [*] http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Inline.html Hmmm. I was going to say, well, that's gcc specific, while wx needs to support other compilers. But I think the conclusion you draw isn't gcc specific at all: C++ 3.2/3 and 7.1.2/3 both say | An inline function shall be defined in every translation unit | in which it is used. Be that as it may, some of the compilers wx supports predate the standard: msvc 4.2 from 1996 or so, and borland 5.0 from early 1997, IIRC. And, of course, dllimport isn't even in the standard. The reasons for writing some wx functions as inline dllimport are probably lost in the mists of time, and I don't think anyone has a copy of every supported compiler to test with. But the wx folks have plenty of negative experience making changes that seem valid, only to find that they broke someone's code, and I understand their reluctance to change things like this. Yet I do very much want to use '-Werror' with my own code that includes wx headers. For now, I'll just stick with an earlier version than gcc-3.4.5 . Eventually, I may have to patch my local copy of wx, unless gcc-4.x provides a way to inhibit this specific diagnostic. |