Article View: comp.os.os2.programmer
Article #769Re: Re: EMX/GCC library support
From: Colin Jensen
Date: Wed, 12 Aug 1992 16:54
Date: Wed, 12 Aug 1992 16:54
34 lines
2028 bytes
2028 bytes
In article <1992Aug11.195534.3249@njitgw.njit.edu> dic5340@hertz.njit.edu (David Charlap) writes:
>Rather than edit the .h files (which gets messy if the headers are
>updated in the future - you'd have to re-update them), it's easier to
>define them as "C" in your application like this:
>
>extern "C" {
> #define ....
> #include <os2.h>
>}
Actually, if you are using gcc/2 as your C++ compiler, it is unneccesary
to use extern "C" {} since the header files already solve this problem
for both C and C++ by explicit use of the asm directive.
[All extern "C" does is remove the type-safe linkage (i.e. name mangling)
from the functions listed within the curly brackets. But since gcc
expects there to be no underscores in front of symbols, and DLLs have no
underscore, gcc comes with header files that explicitly name (via the
asm directive) the symbols that represent each function.
For example for DosOpen you will see a line in the header file that looks
something like:
ULONG DosOpen(woof, woof) asm("DosOpen");
This line tells gcc C that DosOpen is represented by the symbol "DosOpen"
rather than the normal "_DosOpen".
For gcc C++, it tells the compiler to use the symbol "DosOpen" instead of
the crazy name-mangled C++ name that would be used by default.
]
Disclaimer: This probably is not true for EMX/GCC, but since I don't use EMX,
except for Emacs :-), I can't say for sure.
--
Colin Jensen (cjensen@ampex.com)
Technical Details
Message-ID:
<1992Aug12.165451.19939@ampex.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!mips!mips!ampex!cjensenReferences:
<1992Aug7.201552.23788@csc.ti.com> <1992Aug10.094324.269@newsserver.rrzn.uni-hannover.de> <1992Aug11.195534.3249@njitgw.njit.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!mips!mips!ampex!cjensen From: cjensen@ampex.com (Colin Jensen) Subject: Re: Re: EMX/GCC library support Message-ID: <1992Aug12.165451.19939@ampex.com> Sender: usenet@ampex.com (News Poster) Nntp-Posting-Host: mer-s4-14 Organization: Ampex Corporation, Redwood City CA References: <1992Aug7.201552.23788@csc.ti.com> <1992Aug10.094324.269@newsserver.rrzn.uni-hannover.de> <1992Aug11.195534.3249@njitgw.njit.edu> Date: Wed, 12 Aug 1992 16:54:51 GMT Lines: 34