Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I pass NULL to the va_list function parameter?

I wanna pass NULL to the 4th param of the following function:

bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, **va_list args**);

like this:

CCMenuItemToggle::initWithTarget(this, menu_selector(GOSound::toggleButtonCallback), NULL, NULL);

It's ok when I build it in XCode (clang3.1). But when I port the code to android ndk (g++4.7), it fails to compile:

no viable conversion from 'int' to 'va_list' (aka '__builtin_va_list')

How should I deal with it?

like image 597
smilingpoplar Avatar asked Mar 10 '13 11:03

smilingpoplar


1 Answers

I assume your code will work if you just use an empty va_list instead of NULL.

CCMenuItemToggle::initWithTarget( this, menu_selector(GOSound::toggleButtonCallback)
                                , NULL, va_list() );

Edit: Maybe this alternative solution works with both compilers.

va_list empty_va_list = va_list();
CCMenuItemToggle::initWithTarget( this, menu_selector(GOSound::toggleButtonCallback)
                                , NULL, empty_va_list );
like image 179
Thomas Avatar answered Sep 25 '22 07:09

Thomas