Thread: initiating a va_list without va_start

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733

    initiating a va_list without va_start

    To keep the context short & sweet:
    Code:
    typedef struct _NEW_PAWS
    {
    	NEW_PAWBUF buff;
    	pawhhs args;
    	va_list va;
    } NEW_PAWS;
    
    #define INIT_NEW_PAWS { INIT_NEW_PAWBUF, NULL, }
    I need to know what to put in the 3rd parameter that's cross-compiler/platform safe as the equivalent of 0,false,NULL etc, the args member will be used to check if the va member should be used, I'm using this with a global "class" initialiser something like:
    Code:
    ...
    ud = PawAlloc( NULL, cls->size );
    if ( ud )
    {
    	memset( ud, 0, cls->size );
    	if ( cls->init && cls->init( id, ud, cfg ) != 0 )
    	{
    		PawAlloc( ud, 0 );
    		return -1;
    	}
    	return id;
    }
    ...
    return -1;
    So forcing an extra member isn't really a good solution and I don't want the compiler refusing to compile in specific setups just because the va member wasn't initialised.

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    I think I found my solution:
    Code:
    typedef struct _NEW_PAWS
    {
        NEW_PAWBUF buff;
        pawhhs args;
        va_list *va;
    } NEW_PAWS;
     
    #define INIT_NEW_PAWS { INIT_NEW_PAWBUF, NULL, NULL }
    ...
    PAW_API pawd PawMakeStringv( pawhhs args, va_list va )
    {
    	NEW_PAWS new = INIT_NEW_PAWS;
    	new.args = args;
    	new.va = (va_list*)&va;
    	return PawTakeID( &clsPAWS, &new );
    }
    Seems to work without issue, still testing though

    Edit: Just realised I forgot to put in the * character before va in my example struct

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Do I need to va_end before va_start ?
    By Richardcavell in forum C Programming
    Replies: 3
    Last Post: 03-07-2011, 06:06 AM
  2. Understanding va_start(ap, v) in STDARG.H
    By thinhare in forum C Programming
    Replies: 7
    Last Post: 09-26-2005, 03:53 AM
  3. Initiating a file transfer with a CGI script in C++
    By paladin217 in forum C++ Programming
    Replies: 2
    Last Post: 10-04-2002, 06:21 AM
  4. Initiating command prompt execution
    By bluecoder in forum Windows Programming
    Replies: 2
    Last Post: 07-26-2002, 07:00 PM
  5. va_start, va_end, va_list
    By Garfield in forum Windows Programming
    Replies: 2
    Last Post: 10-27-2001, 07:55 PM

Tags for this Thread