* What is the correct prototype of md_atof?
@ 2003-11-19 23:25 Kazu Hirata
2003-11-19 23:33 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Kazu Hirata @ 2003-11-19 23:25 UTC (permalink / raw)
To: binutils
Hi,
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?
Kazu Hirata
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: What is the correct prototype of md_atof?
2003-11-19 23:25 What is the correct prototype of md_atof? Kazu Hirata
@ 2003-11-19 23:33 ` Ian Lance Taylor
2003-11-19 23:43 ` Kazu Hirata
0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2003-11-19 23:33 UTC (permalink / raw)
To: Kazu Hirata; +Cc: binutils
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: What is the correct prototype of md_atof?
2003-11-19 23:33 ` Ian Lance Taylor
@ 2003-11-19 23:43 ` Kazu Hirata
2003-11-19 23:53 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Kazu Hirata @ 2003-11-19 23:43 UTC (permalink / raw)
To: ian; +Cc: binutils
Hi Ian,
> > 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?
Oops. I meant to say that so many gas/config/tc-*.c has char for the
first argument of md_atof.
> 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'.
The only reason why I said "char" is correct is that the first
argument contains a character. "int" wouldn't be wrong, but I am not
comfortable with the mismatch between the definition and the
prototype. Should I change every md_atof to use char for the first
argument?
Kazu Hirata
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: What is the correct prototype of md_atof?
2003-11-19 23:43 ` Kazu Hirata
@ 2003-11-19 23:53 ` Ian Lance Taylor
0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2003-11-19 23:53 UTC (permalink / raw)
To: Kazu Hirata; +Cc: binutils
Kazu Hirata <kazu@cs.umass.edu> writes:
> > If we convert to C90 and use a prototype style definition, then we can
> > safely switch to `char'.
>
> The only reason why I said "char" is correct is that the first
> argument contains a character. "int" wouldn't be wrong, but I am not
> comfortable with the mismatch between the definition and the
> prototype. Should I change every md_atof to use char for the first
> argument?
Yes, provided every md_atof uses a prototype style definition.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-11-19 23:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-19 23:25 What is the correct prototype of md_atof? Kazu Hirata
2003-11-19 23:33 ` Ian Lance Taylor
2003-11-19 23:43 ` Kazu Hirata
2003-11-19 23:53 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).