extern char **environ and msvc
Frank Richter
frank.richter at gmail.com
Wed May 25 16:04:02 CDT 2011
On 25.05.2011 22:52, Stefan Dösinger wrote:
> I'm sorry for the German, I don't know how to change this. Google finds only
> other clueless people. Either way it says something like "Inconsistent DLL
> binding"
I believe the English translation is “inconsistent DLL linkage”.
>
> The line in stdlib.h declares _environ as
>
> _CRTIMP extern char ** _environ; /* pointer to environment table */
>
> The compiler just writes a warning, but afterwards linking fails:
>
> 1>loader.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__environ".
>
> The linker complains about an "unresolved external symbol __environ". Removing
> our declaration of environ fixes the warning, link error and libwine seems to
> work OK.
>
> I don't know what the proper fix is, please advise. Maybe this code shouldn't
> be compiled at all? I don't think I need the loader code on Windows.
The underlying issue is probably the _CRTIMP - that's most likely
_declspec(dllimport) in MSVC. This matters, as DLL-imported and “plain”
extern variables are handled differently on Windows.
IIRC DLL export/import of variables is indirect - when DLL-importing a
variable you really import a _pointer_ to the variable. So accessing the
variable dereferences some pointer. “extern” variables, otoh, are
accessed directly (resolving the actual variable location is handled at
link-time).
-f.r.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110525/035520c8/attachment.pgp>
More information about the wine-devel
mailing list