1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem with macros for creating get/set functions

Discussion in 'Win32' started by Dawoodoz, Aug 28, 2010.

  1. Dawoodoz

    Dawoodoz New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    "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:
    #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;
        }
    };
     

Share This Page