[RESOLVED] Problem with macros for creating get/set functions
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: [RESOLVED] Problem with macros for creating get/set functions

Threaded View

  1. #1
    Join Date
    Jul 2010
    Posts
    88

    [RESOLVED] Problem with macros for creating get/set functions

    "error C2084: function 'D3DXVECTOR3 FName(int)' already has a body"
    I am using Visual Studio 2005 professional.

    I don't understand why FName (function name) is taken directly as the function name instead of being replaced with the macro argument.

    Code:
    // Actual syntax
    #define Get_InsProp3(FName,PName,PPart1,PPart2,PPart3,DType,DefVal) inline DType FName (int Instance) { Object_Instance* pInstance; if (GameEngine_Object_Instance_IsValid(Instance)) { pInstance = (Object_Instance*)Instance; return DType(pInstance->##PName##.##PPart1, pInstance->PName##.##PPart2, pInstance->PName##.##PPart3); } else { ReportBadReference_Instance(L#FName, Instance); return DType##DefVal; } };ReportBadReference_Instance(L#FName, Instance); return DefVal; } };
    
    // Simplified with multiple lines
    #define Get_InsProp3(FName,PName,PPart1,PPart2,PPart3,DType,DefVal)
    inline DType FName (int Instance) {
        Object_Instance* pInstance;
        if (GameEngine_Object_Instance_IsValid(Instance)) {
            pInstance = (Object_Instance*)Instance;
            return DType(pInstance->##PName##.##PPart1, pInstance->PName##.##PPart2, pInstance->PName##.##PPart3);
        } else {
            ReportBadReference_Instance(L#FName, Instance); return DType##DefVal;
        }
    };
    Last edited by Dawoodoz; August 26th, 2010 at 01:27 PM. Reason: Code tags

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center