
itoa function caused "conflicting types" error
Quote:
>Hi,
>I've not been using C for quite a while. I recall that if a programmer
>names a function itoa, the same as the standard C function name, there
There is no standard C function caled itoa (although there is one called
atoi).
Quote:
>is a way to choose which one the programmer intends to use.
In general defining a function that clashed with a standard library function
results in undefined behaviour, the whole program is effectively invalid.
There is no standard way around this other than to rename the offending
function.
Quote:
>In my case
>I am working on compiling a fairly large editor that someone wrote and
>it has an 'itoa' function that is different from the standard C
>function as defined in stdlib. Is there a GCC compile switch that I can
>use to override the standard C definition of the function named itoa?
Since itoa is not a standard C function a conforming implementation
should not be declaring it in stdlib.h or any other standard header.
Your compiler may have options to "turn off" non-standard extensions
such as this. However gcc is very often used with system-supplied
headers so you may have to research the particular headers you are
using as much as gcc.
For more information about gcc try asking in gnu.gcc.help, for information
about your system headers ask in a newsgroup related to the system
or library that they are supplied with. I don't normally recommend
rummaging system headers but in this case it might be worth while to take
a look. Non-standard features are often included conditionally through
the use of #if and #ifdef and control macros. You may find it set up
to exclude extensions when certain macros are defined (e.g. with -D... on
the compiler command line). However things can be more complex than they
first appear and if you can find the "official" method in the
documentation.
Quote:
>(without changing the programmer written itoa to my_itoa)
That would probably be the most sensible approach. If you have the complete
source code it would be trivial to search and replace all instances
of itoa in it.
Please don't be rude. You expect us to read your question here, you can
at least have the basic courtesy to read our responses here. It helps
you to because an incorrect response will almost certainly be corrected.
--
-----------------------------------------
-----------------------------------------