callback function declaration not compiling
Hello,
I'm trying to port an app from Windows to Linux, and when switching from dev environment the code below does not compile... Anyone would had any hint on the reason and how to fix it?
new dev environment is codeblocks, with MinGW compiler.
excerpt of aku.h
Code:
#define AKU_DECLARE_FUNC_ACCESSORS(funcname) \
AKU_API AKU##funcname##Func AKUGetFunc_##funcname (); \
AKU_API void AKUSetFunc_##funcname ( AKU##funcname##Func func );
// Callback management
typedef void ( *AKUEnterFullscreenModeFunc ) ();
typedef void ( *AKUExitFullscreenModeFunc ) ();
AKU_DECLARE_FUNC_ACCESSORS ( EnterFullscreenMode )
AKU_DECLARE_FUNC_ACCESSORS ( ExitFullscreenMode )
error at build time is:
Code:
../../src/aku/AKU.h|44|error: expected constructor, destructor, or type conversion before ‘(’ token|
where line 44 is obviously
Code:
AKU_DECLARE_FUNC_ACCESSORS ( EnterFullscreenMode )
This code used to work under VS2008 though. Any idea where the error may come from?
thanks in advance.
Berteh.
Re: callback function declaration not compiling
Quote:
Originally Posted by
berteh
Hello,
I'm trying to port an app from Windows to Linux, and when switching from dev environment the code below does not compile...
If I took that code you posted, it won't compile for me because AKU_API is not defined anywhere.
Regards,
Paul McKenzie
Re: callback function declaration not compiling
Code:
typedef void AKU_API;
#define AKU_DECLARE_FUNC_ACCESSORS(funcname) \
AKU_API AKU##funcname##Func AKUGetFunc_##funcname (); \
AKU_API void AKUSetFunc_##funcname ( AKU##funcname##Func func );
// Callback management
typedef void ( *AKUEnterFullscreenModeFunc ) ();
typedef void ( *AKUExitFullscreenModeFunc ) ();
AKU_DECLARE_FUNC_ACCESSORS ( EnterFullscreenMode )
AKU_DECLARE_FUNC_ACCESSORS ( ExitFullscreenMode )
Now when given this, the error is that you're declaring those functions twice within the same source unit. The first time with a typedef, and the second time using the AKU_DECLARE_FUNC_ACCESSORS macro.
Regards,
Paul McKenzie