OK I'm writing a dll in C (can't use C++), and I was using the
_declspec(dllexport) to export the functions, however it crashed when
making calls because I didn't have a DEF file.

Now I understand you only need a DEF file if you don't use
_declspec(dllexport) or if you're using _stdcall calling convention,
which I'm not.

Is this just a C requirement, and not needed in C++?

Re: dllexport and DEF files!! by Bruno

Bruno
Wed Sep 20 10:36:37 CDT 2006

> OK I'm writing a dll in C (can't use C++), and I was using the
> _declspec(dllexport) to export the functions, however it crashed when
> making calls because I didn't have a DEF file.

Why? This is by no means a requirement.

> Now I understand you only need a DEF file if you don't use
> _declspec(dllexport) or if you're using _stdcall calling convention,
> which I'm not.

Technically speaking, the calling convention has no influence.
For exporting, you can use either the declspec or the DEF files.

What i usually do is this:

#ifdef __cplusplus
extern "C"{
#endif

_declspec(dllexport) int _cdecl fun1(...);
_declspec(dllexport) int _cdecl fun2(...);

#ifdef __cplusplus
}
#endif


--

Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"




Re: dllexport and DEF files!! by Carl

Carl
Wed Sep 20 10:43:58 CDT 2006

Keith wrote:
> OK I'm writing a dll in C (can't use C++), and I was using the
> _declspec(dllexport) to export the functions, however it crashed when
> making calls because I didn't have a DEF file.

What do you mean by "crashed"? Lack of export definitions (either by
__declspec or .DEF file) can only cause linker errors. If you mean that the
program crashed at runtime, then you most like have a calling convention
mismatch.

>
> Now I understand you only need a DEF file if you don't use
> _declspec(dllexport) or if you're using _stdcall calling convention,
> which I'm not.
>
> Is this just a C requirement, and not needed in C++?

You can use either method with either language - your problem is not related
to the use (or non-use) of a DEF file.

-cd