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*/ )
This article has been dead for over six months. Start a new discussion instead.