A problem about syntax

I find that a kind of C syntax in the files of SDL
but I don’s know what they mean;
as below:

in the file SDL_video.h:

 extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name,

Unit32 flags);

I don’t know ‘DECLSPEC’ means.

thanks for your help

Regards,
Andy

It’s for the benifit of the VC++ compiler… DECLSPEC is a macro that is
replaced by a calling convention on Win32 platforms… This calling
convention can be something like “stdcall” or “fastcall”… This
controls 2 things:

  1. It controls how arguments and returned values are passed to a
    function when executed. (which CPU registers and parts of the stack are
    used)

  2. It also controls the “name mangling” performed on the fuction names
    (and in C++ the types of the argument lists)… this prevents a function
    expecting one calling convention to be called using another.

On non-Windows compilers this macro is set to an empty string, and
ignored.

Hope you found this useful,

-LorenOn Tue, 2002-12-03 at 21:49, huangwei at sunplus.com.cn wrote:

I find that a kind of C syntax in the files of SDL
but I don’s know what they mean;
as below:

in the file SDL_video.h:

 extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name,

Unit32 flags);

I don’t know ‘DECLSPEC’ means.

thanks for your help

Not quite. It’s set to __declspec(dllexport) or __declspec(dllimport),
which define the DLL interface (eg. tells the linker to export a symbol to
the DLL).

Calling conventions (#1) and name mangling (or as MS euphamistically calls
it, “decoration”) (#2) are controlled with __cdecl, __fastcall and __stdcall,
and are independant of __declspec.On Tue, Dec 03, 2002 at 11:04:13PM -0800, Loren Osborn wrote:

It’s for the benifit of the VC++ compiler… DECLSPEC is a macro that is
replaced by a calling convention on Win32 platforms… This calling
convention can be something like “stdcall” or “fastcall”… This
controls 2 things:

  1. It controls how arguments and returned values are passed to a
    function when executed. (which CPU registers and parts of the stack are
    used)

  2. It also controls the “name mangling” performed on the fuction names
    (and in C++ the types of the argument lists)… this prevents a function
    expecting one calling convention to be called using another.


Glenn Maynard