prototype my function, please...

Dan Mercer mercer at ncrstp.StPaul.NCR.COM
Fri May 25 10:01:51 AEST 1990


In article <1231 at wet.UUCP> noah at wet.UUCP (Noah Spurrier) writes:
:
:
:I get the bad feeling that I am going to get flamed for this... But I can
:see no reason why my Turbo C compiler does not like the way I prototype
:the following program.
:
:#include <stdio.h>
:
:/* Prototype */
:void x (float);
:
:void main ()
:{
: x ((float)1);
:}
:
:void x (y)
:float y;
:{
: printf ("%f",y);
:}
:
:I keep getting a type mismatch error in function x() parameter float y;
:If I delete the prototype line the program works fine, but with warnings.
:
:Also just to make sure I was seeing straight I tried this nearly identical
:program. 
:
:#include <stdio.h>
:
:/* Protoypte */
:void x (int);
:
:void main ()
:{
: x (1);
:}
:
:void x (y)
:int y;
:{
: printf ("%d",y);
:}
:
:This works just fine, no warnings, no errors. Maybe I can't see the forest for
:the trees, so I am hoping someone else can take a chain-saw to this one...
:Oh if had only paid attention that day in class when they explain EXACTLY why
:I can't do what I am trying to do.
:
:I hope anyone can help...
:
:yours,
:
:Noah Spurrier
:noah at WET.UUCP


Maybe try the following:

/* Prototype */
void x (float);

void main ()
{
 x ((float)1);
}

void x (float y)   <========    change to ANSI declaration style
{
 printf ("%f",y);
}

My Turbo C has a fit if I mix  ANSI declarations with old style
declarations (makes porting code a real bitch)
-- 

Dan Mercer
Reply-To: mercer at ncrstp.StPaul.NCR.COM (Dan Mercer)



More information about the Comp.lang.c mailing list