Very angry: "two or more data types in declaration"

This is a discussion on Very angry: "two or more data types in declaration" within the C Programming forums, part of the General Programming Boards category; I've got a header file, and it's accompanying .c file, both of which work fine if I use them in ...

  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Very angry: "two or more data types in declaration"

    I've got a header file, and it's accompanying .c file, both of which work fine if I use them in one program. When I compile them linked to another, I get the following:
    Code:
    gameutils.h:7: two or more data types in declaration of 'rnumber'
    What ........es me off about this whole thing is that it works flawlessly in another program:

    gcc -Wall -o successtest successtest.c gameutils.c


    The identical usage generates errors when I try and use it elsewhere:

    gcc -Wall -o game game.c gameutils.c

    Hell, I can even do it seperately:

    gcc -Wall -c -o gameutils.o gameutils.c
    ... no errors or warnings
    gcc -Wall -c -o game game.c
    ... error here

    Header:
    Code:
    #ifndef GAMEUTILS
    #define GAMEUTILS
    
    #define UNMin 1
    #define UNMax 10000
    
    extern int rnumber( int, int );
    extern int success( int, int );
    
    #endif
    The only difference I can see in the two would be executables is the call to rnumber.
    The first uses integers returned by atoi, and it works fine.
    The second uses enum values from non-typed enums:
    Code:
    enum
    {
        Foo = 1,
        Bar = 5,
        ....
    };
    Then the call:

    int x = rnumber( foo, bar );

    Google gives me jack. Mainly people asking for the same fix.

    Also, if I cange the #defines to an enum statement:
    Code:
    enum { UNMin = 1, UNMax = 10000 };
    I get:
    Code:
    two types specified in one empty declaration
    What really angers me here is that in one program, I get neither of these problems. In the second, both show up.

    Any ideas?

    Quzah.
    Hope is the first step on the road to disappointment.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    # 1 "game.c"
    # 1 "/usr/include/stdio.h" 1 3
    Unfortunately, that's greek to me.

    Quzah
    Hope is the first step on the road to disappointment.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Salem
    That's just line 1 of game.c including stdio.h

    search for where gameutil.h is included, and find your declarations which immediately follow it.
    Ah hah! I owe you a cold one. The header before it was a list of enums. There were three headers total. One before and one after. In the header before of it, the list of enums was missing the trailing ;

    Thanks a million.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  4. Need help with simple data types
    By partnole in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 08:36 AM
  5. Using enumerated data types
    By SXO in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2001, 06:26 PM

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