Thread: error: conflicting types for 'sbp_pos_lookup_1'

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    error: conflicting types for 'sbp_pos_lookup_1'

    Hi,

    I got this error when I compiled the program in Linux platform:

    'error: conflicting types for 'sbp_pos_lookup_1'
    'error: previous declaration of 'sbp_pos_lookup_1' was here

    but it works fine and has been successfully compiled in AIX.

    This is the part of the code:
    #ifdef __STDC__
    struct sbp_pos_msg *sbp_pos_lookup_1(struct sbp_pos_msg *);
    .
    .
    #else
    struct sbp_pos_msg *sbp_pos_lookup_1();
    .
    .
    #endif

    Any input? Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    'error: conflicting types for 'sbp_pos_lookup_1'
    'error: previous declaration of 'sbp_pos_lookup_1' was here

    So does your implementation of sbp_pos_lookup_1 actually match the declaration when STDC is defined (which it is under GCC/Linux)

    #ifdef __STDC__
    struct sbp_pos_msg *sbp_pos_lookup_1(struct sbp_pos_msg *);
    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.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    error: conflicting types for 'sbp_pos_lookup_1'

    Thanks, Salem for your response.
    Yes, it matches the declaration. I'm actually getting the error in this line
    struct sbp_pos_msg *sbp_pos_lookup_1();

    It was actually successfully compiled and it works fine in AIX, but when I tried to compile in Linux, I'm getting this error.
    error: conflicting types for 'sbp_pos_lookup_1'

    Any input? Thanks.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    So what does it look like at the "previously declared as line"?
    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.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    error: conflicting types for 'sbp_pos_lookup_1'

    That is the first statement after the 'else' statement. That's where I'm getting the compile error.

    This is the part of the code:
    #ifdef __STDC__
    struct sbp_pos_msg *sbp_pos_lookup_1(struct sbp_pos_msg *);
    .
    .
    #else
    struct sbp_pos_msg *sbp_pos_lookup_1();
    .
    .
    #endif

    Any idea? Thanks.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Yes, but itīs the one "previously declared as" which is important.

    Mostly, such error messages print a filename and a line number. Maybe you should post those as well.
    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.

  7. #7
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    error: conflicting types for 'sbp_pos_lookup_1'

    Here are the files indicated in the error:

    sbp_pos.c:21: error: conflicting types for 'sbp_pos_lookup_1'
    sbp_svr.h:80: error: previous declaration of 'sbp_pos_lookup_1' was here

    Line 21 points to this part of the code which is after the #else statement
    #else
    struct sbp_pos_msg *sbp_pos_lookup_1(); <---Line 21

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Why is your .c file also prototyping the function already prototyped by the .h file?

    > #else
    And does the .c / .h have the same pre-processor logic?


    10 lines either side of the actual error line would be useful.

    As would knowing where struct sbp_pos_msg is actually declared.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. invalid types 'int[int]' for array subscript
    By kolistivra in forum C++ Programming
    Replies: 6
    Last Post: 12-11-2010, 12:57 PM
  2. Replies: 6
    Last Post: 08-23-2008, 01:16 PM
  3. The Interactive Animation - my first released C program
    By ulillillia in forum A Brief History of Cprogramming.com
    Replies: 48
    Last Post: 05-10-2007, 02:25 AM
  4. List or container to hold types
    By tony_chestnut in forum C++ Programming
    Replies: 6
    Last Post: 04-21-2006, 11:46 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM