itoa function caused "conflicting types" error 
Author Message
 itoa function caused "conflicting types" error

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
is a way to choose which one the programmer intends to use.  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?
(without changing the programmer written itoa to my_itoa)


--Enoch

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 13 Apr 2002 03:00:00 GMT  
 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 is no standard C function named itoa.

--

__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com



Sat, 13 Apr 2002 03:00:00 GMT  
 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.

--
-----------------------------------------


-----------------------------------------



Sat, 13 Apr 2002 03:00:00 GMT  
 itoa function caused "conflicting types" error

Quote:


writes:

> >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).

> >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.

> >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.

> >(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.

> --
> -----------------------------------------


> -----------------------------------------

Thank you very much for the comprehensive answer.  I made a mistake of
typing itoa when I really meant atoi. I'd like to apologize for that.

Atoi is defined in the stdlib.h as having 3 arguments but the
application source codes define atoi as having only 1 argument.  Both
are of type character pointer.

Well, let me try compiling with MSVC++ just to see if the problem goes
away.

Enoch

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 13 Apr 2002 03:00:00 GMT  
 itoa function caused "conflicting types" error

...

Quote:
>Thank you very much for the comprehensive answer.  I made a mistake of
>typing itoa when I really meant atoi. I'd like to apologize for that.

>Atoi is defined in the stdlib.h as having 3 arguments but the
>application source codes define atoi as having only 1 argument.  Both
>are of type character pointer.

In that case your code rerally is broken and needs fixing by renaming
the atoi() function it defines to something else.

Quote:
>Well, let me try compiling with MSVC++ just to see if the problem goes
>away.

The problem is going to plague you on various compilers until you fix it.
Fixing it shouldn't require a great deal of effort and will be the
least painful option in the long run.

--
-----------------------------------------


-----------------------------------------



Sat, 13 Apr 2002 03:00:00 GMT  
 itoa function caused "conflicting types" error

comp.lang.c:

        [snip]

Quote:
> Thank you very much for the comprehensive answer.  I made a mistake of
> typing itoa when I really meant atoi. I'd like to apologize for that.

> Atoi is defined in the stdlib.h as having 3 arguments but the
> application source codes define atoi as having only 1 argument.  Both
> are of type character pointer.

> Well, let me try compiling with MSVC++ just to see if the problem goes
> away.

> Enoch

There seems to be some confusion here.  The prototype for the standard
ANSI/ISO function atoi is:

int atoi(const char *s);

The ANSI/ISO standard function accepts only one argument.  Are you
sure you are not still confusing atoi() and itoa()?  Some compilers
supply a non-standard extension by that name, and some of them (but
not all of them) take 3 parameters.

I have never heard of an implementation of atoi() which takes other
than the standard single pointer to char.

Jack Klein
--
Home: http://jackklein.home.att.net



Sat, 13 Apr 2002 03:00:00 GMT  
 itoa function caused "conflicting types" error

Quote:


writes:

> ...

> >Thank you very much for the comprehensive answer.  I made a mistake
of
> >typing itoa when I really meant atoi. I'd like to apologize for that.

> >Atoi is defined in the stdlib.h as having 3 arguments but the
> >application source codes define atoi as having only 1 argument.  Both
> >are of type character pointer.

> In that case your code rerally is broken and needs fixing by renaming
> the atoi() function it defines to something else.

> >Well, let me try compiling with MSVC++ just to see if the problem
goes
> >away.

> The problem is going to plague you on various compilers until you fix
it.
> Fixing it shouldn't require a great deal of effort and will be the
> least painful option in the long run.

> --
> -----------------------------------------


> -----------------------------------------

Thank you very much.  I changed itoa to my_itoa and the problem was
resolved.

--Enoch

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 14 Apr 2002 03:00:00 GMT  
 itoa function caused "conflicting types" error


Quote:

> comp.lang.c:

>    [snip]

> > Thank you very much for the comprehensive answer.  I made a mistake
of
> > typing itoa when I really meant atoi. I'd like to apologize for
that.

> > Atoi is defined in the stdlib.h as having 3 arguments but the
> > application source codes define atoi as having only 1 argument.
Both
> > are of type character pointer.

> > Well, let me try compiling with MSVC++ just to see if the problem
goes
> > away.

> > Enoch

> There seems to be some confusion here.  The prototype for the standard
> ANSI/ISO function atoi is:

> int atoi(const char *s);

> The ANSI/ISO standard function accepts only one argument.  Are you
> sure you are not still confusing atoi() and itoa()?  Some compilers
> supply a non-standard extension by that name, and some of them (but
> not all of them) take 3 parameters.

> I have never heard of an implementation of atoi() which takes other
> than the standard single pointer to char.

> Jack Klein
> --
> Home: http://jackklein.home.att.net

It was itoa causing the problem.  It's odd that there was a #define
itoa My_itoa at the top level that the compiler missed. The same
sources compiled on a Unix system without any problem, and the
executables run flawlessly.  I fixed the problem, after consulting you
folks, by editing all itoa function calls and the function itoa itself.
Well, cooledit runs on "UWIN" but the port is not quite complete yet.
The compiler I use is MSVC4 and/or GCC 2.95 depending on which one
imake or configure detects.

Enoch
http://www.wipro.com/uwin/

PS I'm just doing recreational computing.

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 16 Apr 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Attribute "id" causes error in ATL7

2. What causes "Error spawning cl.exe"

3. bcp_init causes "unresolved external" error

4. What is causing "error LNK2005:..."?

5. ISAPI extension causes "Internal Server Error"

6. Variables and types of type "Type"

7. how do I do an "itoa"?

8. ODBC Error - "Restricted data type attribute violation", code 07006

9. MIDL "type" Error

10. Error "free"-ing "malloc"-ed memory

11. Function without a "return type"?

12. conflicting "BOOL" typedefs

 

 
Powered by phpBB® Forum Software