error: conflicting types for 'basename'

This is a discussion on error: conflicting types for 'basename' within the C Programming forums, part of the General Programming Boards category; I run this version of gcc $ gcc --version gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2) My program uses a ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    58

    error: conflicting types for 'basename'

    I run this version of gcc
    $ gcc --version
    gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)


    My program uses a custom written library that has a function named basename with its own set of parameters. My question is, if I want to use the GNU version of basename, how can I do it?

    I tried including this in my header

    #define _GNU_SOURCE
    #include <string.h>

    and I get this compiler error:

    x.h:80: error: conflicting types for 'basename'
    /usr/include/string.h:387: error: previous declaration of 'basename' was here

    Is there a way I can tell gcc to ignore the custom version of basename?

    Sam

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    something like:
    Code:
    #if !__GNUC__
    // the custom basename declaration
    #endif
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    58
    Quote Originally Posted by matsp View Post
    something like:
    Code:
    #if !__GNUC__
    // the custom basename declaration
    #endif
    --
    Mats
    But how do I tell gcc to ignore the actual function definition, not just the prototype only, in the custom library?

    Sam

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Functions are taken from libraries in the order the libraries are given to the linker, so if you specify the standard C library first, then the custom library, you will get the standard version.

    Or you could add a similar #if/#endif in the custom library, if you have the source.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

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, 02: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, 03:25 AM
  4. Types, Integral Types, Bytes?!?!?!
    By Kaidao in forum C++ Programming
    Replies: 3
    Last Post: 03-21-2006, 08:15 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

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