I get a warning about recursion when I compile the code below. I think the warning is wrong. Here is the background.

I have two functions which "add a layer" to a DXF file. They have the same names but different parameters.

One of them takes a CString and one a char pointer

The one which takes the CString simply converts the CString into a char* and calls the second.

I thought C++ function signatures would resolve out the two functions, but the compiler says that the first function is recursive because it is calling itself:

warning C4717: 'AddLayer' : recursive on all control paths, function will cause runtime stack overflow

But it is not calling itself (the CString version), it should be callling the char* version.

What have I missed?

const CDxfLayer* const AddLayer (const CString& csName, 
                                 const UINT iAciCol, // gikAcadYellow etc
                                 const int iLineStyle = PS_SOLID,
                                 const bool bVisible = true) 
{
    char szLayerName [_MAX_PATH] ;
    AsciiFromWideChar (szLayerName,_countof(szLayerName),csName.GetString()) ;

    return (AddLayer (szLayerName,iAciCol,iLineStyle,bVisible)) ;
}

const CDxfLayer* CLayerTable::AddLayer (const char* pszName, 
                                        const UINT iAciCol,
                                        const int iLineStyle /* = PS_SOLID */,
                                        const bool bVisible /* = true*/ )

Forget it, my silly error...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.