This is the mail archive of the
mailing list for the GCC project.
Re: Workaround for virtual function/dllimport bug, also patch guidance request
- To: geoff schmidt <gschmidt at mit dot edu>
- Subject: Re: Workaround for virtual function/dllimport bug, also patch guidance request
- From: Mumit Khan <khan at NanoTech dot Wisc dot EDU>
- Date: Fri, 26 Nov 1999 12:33:25 -0600
- cc: cygwin at sourceware dot cygnus dot com, gcc at gcc dot gnu dot org
geoff schmidt <gschmidt@MIT.EDU> writes:
> Since this has come up on the list before, if you're like me and have
> something you really want to compile, a crude but functional
> workaround is to add
> /* Don't let any functions get dllimport'd */
> if (TREE_CODE (decl) == FUNCTION_DECL)
> return 0;
> /* Don't let vtables get dllimport'd; it confuses the assembler */
> if (TREE_CODE (decl) == VAR_DECL
> && DECL_VIRTUAL_P (decl))
> return 0;
> to the beginning of i386_pe_dllimport_p in winnt.c. With this patch
> I've successfully compiled and used a large OOP GUI framework with
> lots of inline and virtual functions as a DLL. Only tested with
I dug through MSVC's output a bit, and it does something similar
I'm going to try out your change and see if it's indeed the solution.
I actually had this change way back (winnt.c still has code commented
out from that experiment), but was never quite sure if it was the right
thing to do or not.
Thanks again for working on this problem.
 MSVC's language front-ends understand the dllimport/dllexport
directives, and do quite a bit more. One example is the following
/* top level. */
__declspec(dllimport) extern int foo();
int (*bar) () = foo;
this will emit different code in C and C++, but that's awkward to do in
language-independent GCC backend in the current implemention in winnt.c.
C will use the thunk (foo), and C++ will use __imp__foo to initialize