Warning : C1801: Implicit parameter-declaration for 'unknown'

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Warning : C1801: Implicit parameter-declaration for 'unknown'

9,071 Views
jcdammeyer
Contributor III
After a bit of searching I find I can turn this warning into either an error or information or even turn it off.  Don't really want to do that because it's useful.  But I really don' t like spurious warnings showing up.  Too many and I have a tendancy to ignore the real once because I'm busy ignoring the ignorable ones.
 
I'm having trouble making the stdio.h library work without the C1801 error showing up.
Code:
void PutString(FILE *f, char * ptr ) {  char ch;  int res;   ch = *ptr; while (ch) {     ch = *ptr;     if (ch != (char)0)                 // (void)putc(ch,f);         res = putc(ch,stdout);   <=== Here's the error.  ptr++; }}

 
As shown in the code fragment I've taken it to the simplest form with stdout directly in the function call and not voiding the result. In the FILE declaration the write_channel declaration obviously doesn't have an argument. and the stdout definition supplies the address of the FILE structure
 
Code:
typedef struct chnl {...int   (*write_channel)();  /* routine for port writes         */} FILE;FILE channels[1];#define  stdout   (&channels[0])
#define putc(c,s)   (*((s)->write_channel))(c)

 
As I see it inside the FILE structure there should be the declarations that avoid this error.  But for some reason I can't get that to work either.  What I tried is a structure called MFILE and the appropriate variables declared with this etc...
 
Is there a solution or do I have to live with this?
 
Thanks
John
Labels (1)
Tags (1)
0 Kudos
3 Replies

1,293 Views
Lundin
Senior Contributor IV
int (*write_channel)();

#define putc(c,s) (*((s)->write_channel))(c)


If this was found in the stdio library, the compiler does not conform to ISO C. Type casting a function pointer to another function pointer of different type is undefined behavior in ISO C.

Perhaps it is safe to patch the compiler lib and write

int (*write_channel)(int);
0 Kudos

1,293 Views
CompilerGuru
NXP Employee
NXP Employee
There is no cast in this code and therefore the remark about ISO C does not apply.
Not specifying anything in an argument list is indeed an implicit parameter declaration, therefore the compiler message is correct and the actual function pointer must have an int as argument. As Lundin suggested, adding the int in the prototype will avoid the message (and catch the incorrect usages of the function pointer the implicit parameter declaration warns about).

Is this indirect output via function pointer necessary? Most of the time for 8/16 bit a simple output via named functions is used.

Daniel
0 Kudos

1,293 Views
CrasyCat
Specialist III
Hello
 
- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
To retrieve that info:
- Start CodeWarrior
- Select Help -> About Freescale CodeWarrior
- Click on "Install Products"
- CodeWarrior version used is displayed on top in the Installed Products dialog.
 
CrasyCat
0 Kudos