Mail Archives: djgpp/2001/01/15/02:30:02
"Nimrod A. Abing" wrote:
> gets turned into a C program by the Bison program. Tim Van Holder's
> suggestion of using ``extern'' language declarations will not (and does
> not) compile because C doesn't recognize the extern "C" construct. Although
Ah, is THAT why it doesn't work? That's easy then: surround them with
#ifdef __cplusplus.
so:
[test.h]
#ifdef __cplusplus
extern "C"
#endif
void MyCplusPlusFunc(int);
or even:
#ifdef __cplusplus
# define CDECL extern "C"
#else
# define CDECL
#endif
CDECL int MyOtherCXXFunc(void);
This still won't allow overloads, but you can use wrappers for those
where
needed.
Oh, and don't count on pointer-to-functions supporting virtual
functions;
IIRC they're stored as offsets to the relevant entry in the virtual
table,
not as pointers to actual functions.
I'm not even sure you can be sure a C++ function without 'extern "C"'
will
have the same calling convention as a C function, so
pointers-to-functions
are not guaranteed to work (I think).
--
Tim Van Holder - Falcon Software N.V.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This message was posted using plain text. I do not endorse any
products or services that may be hyperlinked to this message.
- Raw text -