#__export … How
6 messages in this thread
We are getting compiler errors on this line.
extern "C" char * __export HliSymbolAsCString (HliSymbol sym);
Error is
hlii.h(164) : error C2059: syntax error : 'export'
This is on the March edition of NT. We seem to be having trouble with any
__export
functions. I have been looking in the documentation and can't seem to find
anything
that explains our problem.
Thanks
brian
There is 1 Reply.
Hi Brian,
The compiler keyword __export is obsolete in the context for Win32
programming. The keyword was used to fixup the data and stack segments
under the 16-bit segmented architecture under Windows. Under Win32, exported
functions are simply pointers to those functions so no fixup is necessary.
To retain source code compatibility with 16-bit Windows, you could add the
following define to one of your headers:
#ifdef WIN32
#define __export
#endif
Paul Tissue
Microsoft Developer Support
P.S. You might find this KnowledgeBase article handy:
INF: Exporting Callback Functions [P_W32dev]
ID: Q83706 CREATED: 19-APR-1992 MODIFIED: 24-MAY-1993
3.10
WINDOWS
ENDUSER |
———————————————————————-
The information in this article applies to:
– Microsoft Win32 Software Development Kit (SDK) for Windows NT
version 3.1
———————————————————————-
Summary:
Under Win32, it is not necessary to export callback functions. Windows
versions 3.1 and earlier (Win16) need callback functions primarily for
fixing references to global data and ensuring that EMS memory is not
paged out. Neither of these situations applies to the Windows NT
32-bit operating system.
More Information:
Exports are necessary for any function that must be located by the
GetProcAddress function (dynamic linking), or via a load-time linked
import library (static linking). Both of these linking methods require
that the name or ordinal number of the export be known, and that their
names or ordinal numbers be present in the executable's exported entry
points table. This enables Windows to determine the addresses at run
time.
Load-time linking is done by the loader, which performs this lookup
for all of the imported entry points that an executable needs
(normally by ordinal number). Dynamic linking, done by an application
with GetProcAddress, tells the system to scan by ordinal number or by
name through the exports table of the DLL (dynamic-linked library)
being linked to. Win32 API functions need not be exported.
Exported entries on Win16 are automatically fixed by the linker to
adjust to the appropriate DS. Exporting entries on Win32 just adds
them to the module's exported names and ordinal numbers table; the
linker does not need to "fix" them. For code compatibility with Win16,
you may want to continue to use MakeProcInstance and export all
callbacks.
In short,
Function Type On Win 3.0/3.1 (Win16) On NT (Win32)
————- ———————- —————–
Callbacks Exported or MakeProcInstance Address of fn() *
GetProcAddress Must be exported Must be exported
Static linking Must be exported Must be exported
* Because the MakeProcInstance macro does not do anything, it will
work also.
Additional reference words: exporting
There are 2 Replies.
Thanks a lot for the info.
After I posted my message I got the Dev Network #4 CD and in the Win32 SDK
documentation there is a article titled "The dllexport and dllimport Attributes
(32-bit specific)" that says, "Note that dllexport replaces the __export
keyword". Of course the examples and explanation of dllexport looks nothing
like the functionality of __export.
Thanks for putting me on the write track.
brian
Maybe my use of the __export was incorrect. I am porting a product from
Borland C++ to NT and the _export (1 underscore) was used to export functions
from a DLL without having to put it in the .DEF file. Does C7 offer that
functionality?
Thanks
There are 2 Replies.
Hi Brian,
The 16-bit C7 compiler still supports __export since it is needed in the
16-bit world. I am not sure if a single underscore version is defined but
you could easily define one in a local header. If this issue remains to
plague you in the 16-bit world you might want to drop the folks in the WINSDK
forum about this since they should know about these types of issues.
Paul Tissue
Microsoft Developer Support
PMJI,
> the _export was used to export functions from a DLL without having to put
it in the .DEF file
Yes, this is the way that our 16-bit compilers work. The 32-bit compilers
replace this with _declspec( dllexport ). The Win32 SDK linker doesn't
support this, so you must use a DEF file, but the VC++ for Windows NT linker
works beautifully, so no DEF files are needed. All you'll need to do is
_declspec( dllexport ) int func( );
and this will "export" the DLL function named func() with return type int.
Julie