This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: What is the correct prototype of md_atof?
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: binutils at sources dot redhat dot com
- Date: 19 Nov 2003 18:33:33 -0500
- Subject: Re: What is the correct prototype of md_atof?
- References: <20031119.182525.78714864.kazu@cs.umass.edu>
Kazu Hirata <kazu@cs.umass.edu> writes:
> gas/tc.h has
>
> char *md_atof PARAMS ((int what_statement_type, char *literalP, int *sizeP));
>
> but so many gas/config/tc-*.c has
>
> char *
> md_atof (type, litP, sizeP)
> int type; <- Notice it's int!!
> char *litP;
> int *sizeP;
>
> I noticed this problem while converting tc-h8300.c into ISO-C. To me
> "char" seems to be correct here. What do others think?
Looks like `int' in both places, so what's the problem?
The code uses `int' because in traditional C, with no prototypes, a
char is always promoted to int anyhow. If you write `char' in a
prototype, but then don't use a prototype when defining the function,
the 'char' in the function definition will be promoted to `int'.
Since the function definition then does not match the prototype, there
is a potential problem.
If we convert to C90 and use a prototype style definition, then we can
safely switch to `char'.
Ian