I am using some standard libraries to develop a general interface for some devices. In some part of code I have
//header.h
#ifndef _M_X64
# define GC_CALLTYPE __stdcall
#else
# define GC_CALLTYPE /* default */ //this is my case
#endif
...
typedef int32_t GC_ERROR;
...
/* typedefs for dynamic loading */
#define GC_API_P(function) typedef GC_ERROR( GC_CALLTYPE *function )
GC_API_P(PTLOpen)( TL_HANDLE *phTL );
and in my source files I have
//source1.cpp
TLOpen(&hTl)
//source2.cpp
#define FUNCTION_POINTER(function, ptype, hModule) \
((function) = reinterpret_cast<ptype>(GetProcAddress((hModule), #function))) // What is this #?
GC::PTLOpen TLOpen = 0;
FUNCTION_POINTER(TLOpen, GC::PTLOpen, hModule);
I want to find out:
- What is the
TLopen()
declaration? I replaced macros and got this:
typedef int32_t( GC_CALLTYPE *PTLOpen )( TL_HANDLE *phTL );
But I have learned function pointers differently and I expected something like this:
typedef int32_t( *PTLOpen )( TL_HANDLE *phTL );
Is the above declaration still a function pointer one? What about GC_CALLTYPE
?
What is that
#
sign beforefunction
in definingFUNCTION_POINTER
macro?Where is the body of
TLopen()
function? I have some.lib
and.dll
files to be included. May the body exist in those files in compiled form?