[GRASS5] Win32: _fmode and DLL

Glynn Clements glynn at gclements.plus.com
Sun Feb 5 04:04:54 EST 2006


Radim Blazek wrote:

> It seems that if DLL is used on Windows the binary mode
> (int _fmode = _O_BINARY; ) must be set in a module
> even if it is already set in the library (gis, G__open)
> Does it make sense?

Yes.

On Unix, the loader doesn't care where symbols come from as long as
all imports are ultimately resolved somehow. On Windows, each import
is tied to a specific file (DLL or executable); if a DLL imports a
symbol from the executable, the symbol has to be defined in the
executable, not in a DLL.

> How to do it?
> If I add it to gis.h compiler fails with:
>   multiple definition of `__fmode'

Awkward (unless you manually add it to every module, but that's a fair
amount of work). Thinking out loud:

Change the linking command to link every executable against an object
file which defines that symbol.

Or have a special case for compiling files named "main.c" to add e.g.
-DMAIN then use "#ifdef MAIN" to control whether to define the symbol
(some modules use a different filename, but you could always define
__fmode manually in those few cases).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list