warning: `__builtin_next_arg' called without an argument

This is a discussion on warning: `__builtin_next_arg' called without an argument within the C Programming forums, part of the General Programming Boards category; Does anyone know what this warning means and if I need to worry about it? Maybe also how to fix ...

  1. #1
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545

    warning: `__builtin_next_arg' called without an argument

    Does anyone know what this warning means and if I need to worry about it? Maybe also how to fix it?
    Here's the code it's complaining about:
    Code:
    void DTRACE(    int  level,
    	const char*  fmt,
    		... )
    {
    #if defined( DEBUG ) && defined( ANSI )
    	va_list	pArgs;
    	char*	pArg;
    	char	cArg;
    	char	c;
    	int	iArg;
    	long	lArg;
    
    	if ( GetDebugLevel() < level )
    	{
    		return;
    	}
    
    	va_start( pArgs );  /**** Warning is here. ****/
    
    	while ( (c = *fmt++) )
    	{
    		if ( c != '%' )
    		{
    			putchar( c );
    			continue;
    		}
    
    		c = *fmt++;
    
    		switch ( c )
    		{
    		case 'c':
    			cArg = va_arg( pArgs, int );
    			putchar( cArg );
    			break;
    		case 'i':
    			iArg = va_arg( pArgs, int );
    			printf( "%d", iArg );
    			break;
    		case 'l':
    			lArg = va_arg( pArgs, long );
    			printf( "%ld", lArg );
    			break;
    		case 'u':
    			c = *fmt++;
    
    			switch ( c )
    			{
    			case 'c':
    				cArg = va_arg( pArgs, unsigned int );
    				putchar( cArg );
    				break;
    			case 'i':
    				iArg = va_arg( pArgs, unsigned int );
    				printf( "%ud", iArg );
    				break;
    			case 'l':
    				lArg = va_arg( pArgs, unsigned long );
    				printf( "%lu", lArg );
    				break;
    			default:
    				puts( "Error!  Unknown unsigned format specifier in DTRACE()!" );
    				break;
    			}
    			break;
    		case 's':
    			pArg = va_arg( pArgs, char* );
    			puts( pArg );
    			break;
    		default:
    			puts( "Error!  Unknown format specifier in DTRACE()!" );
    			break;
    		}
    	} /* End of while */
    
    	va_end( pArgs );
    #endif
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    > va_start( pArgs );
    It takes 2 params.
    The 2nd param is the name of the last named parameter, eg.
    va_start( pArgs, fmt );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Oops.
    That would explain the strange output I just got...

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    I'm not sure exactly what your function is for, but you probably don't need all that code. Usually you can get by with calling vprintf() or vfprintf() or something like that. http://www.opengroup.org/onlinepubs/...s/vprintf.html
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. call to realloc() inside a function: memory problem
    By simone.marras in forum C Programming
    Replies: 15
    Last Post: 11-30-2008, 09:01 AM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21