warning: type defaults to `int' in declaration of `s'??

This is a discussion on warning: type defaults to `int' in declaration of `s'?? within the C Programming forums, part of the General Programming Boards category; Hi, Does anyone know why gcc would give me this error on the line in red? warning: type defaults to ...

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

    warning: type defaults to `int' in declaration of `s'??

    Hi,
    Does anyone know why gcc would give me this error on the line in red?
    warning: type defaults to `int' in declaration of `s'
    Code:
    if ( in_file != (char *) NULL ) {
    	char *s;
    
    	if (! chk_suffix( in_file, ".rpc" ) )
    		errorf( 413, "invalid input file name %s", in_file );
    		
    	s = mod_name( in_file, ".rpc", ".h", STRIPDIR );
    	header = STRCPY(s);
    	if ( source == (char *) NULL ) {
    		s = mod_name( in_file, ".rpc", ".c", STRIPDIR );
    		source = STRCPY(s);
    	}
    }
    s is obviously declared as a char* a few lines above it...
    mod_name() returns a char*.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Probably barking up the wrong tree, but is mod_name() properly declared and defined to return a char *?

    Other than that, it looks right to me.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    It's defined as:
    Code:
    extern char *mod_name();

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    Can you provide a minimal complete compilable example?
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Replies: 0
    Last Post: 03-20-2008, 08:59 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. Trouble with case structure
    By fmchrist in forum C Programming
    Replies: 1
    Last Post: 12-31-2005, 03:53 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

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