Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411516 Posts in 69380 Topics- by 58436 Members - Latest Member: GlitchyPSI

May 01, 2024, 07:01:32 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)XCode port of VS project, "has not been declared"
Pages: [1]
Print
Author Topic: XCode port of VS project, "has not been declared"  (Read 1003 times)
SelfTitled
Level 1
*



View Profile WWW
« on: July 29, 2010, 03:56:16 AM »

Ok so I have code similar to the following: (cut down a bit to make it more readable)

Code:
namespace caspianprivate
{
template <typename FunctionType>
struct CScriptRegisterImpl
{
template <FunctionType* Function>
static void Register(const char* name)
{
caspian::CScriptFunctionContainer::Get()->CreateFunction<FunctionType, Function>(name);
}
};
}

namespace caspian
{
class CScriptFunctionContainer : public MapContainer_DefaultCreate<CScriptFunction>, public Singleton<CScriptFunctionContainer>
{
protected:

CScriptFunctionContainer();
};
}

in VS it compiles fine but in XCode it can't find "CScriptFunctionContainer". I can't just have one in front of the other as they have dependencies on each other.

Has anyone come across this sort of thing before? and any ideas about the solution?

EDIT:
the error I get is "'CScriptFunctionContainer' has not been declared" and it complains about the

Code:
caspian::CScriptFunctionContainer::Get()->CreateFunction<FunctionType, Function>(name);

line in the Register function.
Thanks
« Last Edit: July 29, 2010, 04:00:08 AM by SelfTitled » Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #1 on: July 29, 2010, 04:44:33 AM »

The problem is that XCode's compiler (GCC) actually parses template definitions before use, unlike Microsoft's compiler.  This is a flaw in the MS compiler that they pretty much refuse to fix.  The solution is to declare everything before use.

Code:
namespace caspianprivate
{
        template <typename FunctionType>
        struct CScriptRegisterImpl
        {
                template <FunctionType* Function>
                static void Register(const char* name);
        };
}

namespace caspian
{
        class CScriptFunctionContainer : public MapContainer_DefaultCreate<CScriptFunction>, public Singleton<CScriptFunctionContainer>
        {
        protected:

                CScriptFunctionContainer();
        };
}

template <typename FunctionType>
template <FunctionType* Function>
void caspianprivate::CScriptRegisterImpl<FunctionType>::Register(const char* name)
{
    caspian::CScriptFunctionContainer::Get()->CreateFunction<FunctionType, Function>(name);
}
Logged



What would John Carmack do?
SelfTitled
Level 1
*



View Profile WWW
« Reply #2 on: July 29, 2010, 04:55:25 AM »

Wow that was quick, works great. Thank you very much, I've been stuck on this for days.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic