Reputation: 19
I'm using Visual Studio 2010 for win32 application development. Try to compile one existing c++ source file, which was already compiled in GCC (Linux).
#define DEFINE_PORT( parentClass, portClass, name, dataMember, callbacks,... )
do
{
dataMember = new portClass<parentClass>( *this, callbacks );
err = addProvidesPort( name, dataMember );
}
while(0)
Here I'm invoking this function as:
DEFINE_PORT( Service_impl,
ECPDataStoreProvidesPort,
ECP_DATA_STORE,
pECPDataStorePP,
&Service_impl::GetDataVersion,
&Service_impl::SetDataVersion,
&Service_impl::LoadData,
&Service_impl::StoreData,
&ECPService_impl::EnableBlobOperations,
&ECPService_impl::GetCurrentPersonalityIndex,
&ECPService_impl::SwapPersonalities,
&ECPService_impl::UpdateDataStoreBlob,
&ECPService_impl::ExtractDataStoreBlob,
&ECPService_impl::GetConstantPersonalityPtr );
ECPDataStoreProvidesPort
class has constructor defined with 10 no of arguments.
Here VS compiler is not considering the variable length arguments and producing error as portclass
has no overloaded constructor defined for two aruguments.
May anyone please help me out on this? What can be cause and How to handle this error?
Upvotes: 0
Views: 2559
Reputation: 66431
In your expansion, callbacks
is set to &Service_impl::GetDataVersion
, and the rest of the arguments (the ...
) are ignored.
The ...
arguments should be referred to as __VA_ARGS__
in the macro body.
#define DEFINE_PORT( parentClass, portClass, name, dataMember, ... )\
do \
{ \
dataMember = new portClass<parentClass>( *this, __VA_ARGS__ );\
err = addProvidesPort( name, dataMember ); \
} \
while(0)
Upvotes: 1