callback function declaration not compiling
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: callback function declaration not compiling

  1. #1
    Join Date
    May 2011
    Posts
    1

    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,426

    Re: callback function declaration not compiling

    Quote Originally Posted by berteh View Post
    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

  3. #3
    Join Date
    Apr 1999
    Posts
    27,426

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center