error: conflicting types for built-in function ‘tolower’ [-Werror]

c gcc
18,741

Solution 1

tolower is a function from the C library and its identifier is a reserved identifier for use as an identifier with external linkage, even if you don't include the header where it is declared.

You could get rid of the warning by using -fno-builtin but the best is simply to chose another name for tolower.

(C99, 7.1.3p1) "All identifiers with external linkage in any of the following subclauses (including the future library directions) are always reserved for use as identifiers with external linkage."

Solution 2

If you're not using the C standard library for some reason, I won't tell you that's probably a bad idea. Even though the builtin function will probably implicitely link to a libc implementation under certain circumstances beyond your control.

Anyways... Either don't use -Werror, or append -Wno-error or fix your function to look like the real thing:

int tolower(int c);
Share:
18,741

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I have a small RTOS which does not use glibc and I have written own functions (e.g. tolower) in string.c

    When compiling I am getting the error:

    common/string.c:11:6: error: conflicting types for built-in function ‘tolower’ [-Werror]
    

    Is there a CFLAGS to fix this?

    Update Answer: use -fno-builtin