I've been using for a while my own functions like memset(), strcmp() and so on. After I found a bug in one of them I decide to use the GCC's built-in functions instead of mine.
In the section "Other Builtins" of the GCC's manual state the following:
GCC includes built-in versions of many of the functions in the standard C library. These functions come in two forms: one whose names start with the __builtin_ prefix, and the other without.
I am implicitly using the -fno-builtin compiler option by passing the -ffreestanding option to the compiler.The ISO C90 functions abort, abs, acos, asin, atan2, atan, calloc, ceil, cosh, cos, exit, exp, fabs, floor, fmod, fprintf, fputs, frexp, fscanf, isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, tolower, toupper, labs, ldexp, log10, log, malloc, memchr, memcmp, memcpy, memset, modf, pow, printf, putchar, puts, scanf, sinh, sin, snprintf, sprintf, sqrt, sscanf, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncat, strncmp, strncpy, strpbrk, strrchr, strspn, strstr, tanh, tan, vfprintf, vprintf and vsprintf are all recognized as built-in functions unless -fno-builtin is specified
In the section "C Dialect Options" of the GCC's manual it is found the following:
-fno-builtin
-fno-builtin-function
Don't recognize built-in functions that do not begin with ‘__builtin_’ as prefix.
What's written above is what I am doing, however I keep on getting error messages at linking similar to the one below:if you wish to enable built-in functions selectively when using -fno-builtin or -ffreestanding, you may define macros such as:
#define abs(n) __builtin_abs ((n))
#define strcpy(d, s) __builtin_strcpy ((d), (s))
Code: Select all
fat16.c:(.text+0x4fb): undefined reference to 'strncmp'
Any ideas?
Thanks in advance