Richard Henderson wrote > On Wed, Mar 21, 2007 at 04:16:20PM -0000, Dave Korn wrote: > > Presumably there would be no problem in just waiting > until runtime to > > initialise the my_malloc_hook variable dynamically instead > of trying to > > statically initialise it? > > Dunno. One could also wait to expand *__imp_foo, for functions, > until expanding the function call. And then this variable would > receive the address of the import library thunk. > > What does VC++ do? I'm mostly wondering about what pointer > equality guarantees we can make. > > For code like this
extern __declspec(dllimport) void foo(); void Bar() { return foo();} void (* pfn_myfoo)(void) = foo; void my_Bar() { return *pfn_myfoo();} VC++6 uses the __imp__foo reference to resolve the call in Bar, but an import lib thunk _foo to resolve pfn_myfoo and the call in my_Bar. The mingw/cygwin workaround has been to add -mno-fun-dllimport to command line to avoid the problem. Danny > r~ >