0
votes

Can anyone please provide me the full meaning of the following 2 lines of codes?

typedef void DLLEXPORT __stdcall (*DLL_Inquiry) (char *cDriverName, int *iDriverType, int *iDriverBUS, int *iNumberOfChannel);

DLL_Inquiry DRV_PH_Inquiry;

I know that DLLEXPORT is to export a function from the DLL, __stdcall is the x86 argument passing convention.

But still I am not able to get the whole meaning of these 2 lines. May be I am confused with use of function or function pointer in typedef.

2
"_STDCALL is the x86 argument passing convention." There are many calling conventions for the x86. stdcall is the one used by the Win32 API.Michael

2 Answers

1
votes

DLL_Incuiry is a typedef for a pointer to function that takes arguments (char*, int*, int*, int*) and returns no value (return type void). The function also uses the calling convention defined by DLLEXPORT and __stdcall.

DRV_PH_Inquiry is a variable of that type, so if you have function foo:

void DLLEXPORT __stdcall foo (char *cDriverName, int *iDriverType, int *iDriverBUS, int *iNumberOfChannel);

you can then do the assignment:

DRV_PH_Inquiry = foo;   // DRV_PH_Inquiry now points to the function foo
1
votes
typedef void DLLEXPORT __stdcall (*DLL_Inquiry) (
    char *cDriverName, int *iDriverType, int *iDriverBUS, int *iNumberOfChannel);

This defines a typedef for DLL_Inquiry to be a function pointer.

  • The function receives the parameters listed, no need to explain those any further.
  • The function has void return type.
  • The calling convention is __stdcall.
  • The definition of DLLEXPORT is not standard. That will be found in your code. Most likely there will be a header file that defines DLLEXPORT as a macro. For instance, when compiling the DLL, on the Windows platform, it might evaluate to __declspec(dllexport). In any case, only you can know for sure what the definition of DLLEXPORT is.