Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C4839: non-standard use of class 'ATL::CW2AEX<520>' as an argument to a variadic function

Tags:

c++

atl

I'm using Curl in a project and my function is returning a error about CW2AEX..

    const TCHAR* path; 
    const TCHAR* fileName;

    TCHAR url[ MAX_PATH ] = { 0 };
    _stprintf( url, _T( "%s%s" ), path, fileName );

    char errorCode[ CURL_ERROR_SIZE ] = { 0 };
    function( curl, CURLOPT_ERRORBUFFER,        errorCode );    
    function( curl, CURLOPT_HEADER,             0 );
    function( curl, CURLOPT_FOLLOWLOCATION,     1 );
    function( curl, CURLOPT_NOPROGRESS,         0 );
    function( curl, CURLOPT_WRITEDATA,          isMemoryDownload ? ( void* )( &memoryFile ) : ( void* )( &diskFile ) );
    function( curl, CURLOPT_WRITEFUNCTION,      isMemoryDownload ? CNetwork::WriteToMemory : CNetwork::WriteToDisk );
    function( curl, CURLOPT_PROGRESSDATA,       0 );
    function( curl, CURLOPT_PROGRESSFUNCTION,   CNetwork::Pursuit );
    function( curl, CURLOPT_URL,                CW2AEX< sizeof( url ) >( url ) );

My guess is that it should load the value explicitly in order to compile it. Not quiet sure?

like image 326
Sunfluxgames Avatar asked Feb 14 '18 22:02

Sunfluxgames


1 Answers

The error message gives you a hint: for a variadic function argument you have to resolve the type ambiguity and cast the helper class to acceptable type:

function(curl, CURLOPT_URL, (LPCSTR) CW2AEX< sizeof( url ) >( url ) );

You can also make it simpler at minimal cost (using CStringA):

function(curl, CURLOPT_URL, (LPCSTR) CStringA(url));
like image 176
Roman R. Avatar answered Nov 10 '22 07:11

Roman R.