function pointers to functions with struct pointer arguments do not work.
compiling uploaded file foo.c with
sdcc foo.c
results in error:
foo.c:13: error 78: incompatible types from type 'unsigned-int function ( struct Data generic* fixed) fixed' to type 'unsigned-int function ( struct Data generic* fixed) fixed'
tested in sdcc version 3.4 and in current nightly build.
Your foo.c is wrong. Even gcc complaints with
If you change it to
Both gcc and sdcc (the newest snapshot build) accept it.
The key reason is struct Data is neither defined nor declared before its reference in the definition of type T.
Diff:
Diff:
Or you can delete the definition of struct Data, like
sdcc will treat the typedef unsigned int (*T)(struct Data*); as both definition of T and declaration of struct Data.
thanks for your explanations. the idea to test it with gcc didn't come to me, but the error message of gcc would have helped.
I understand the problem, but let's say, a standard which provides syntax to define functions which are impossible to call is a little bit silly then...
As i now understand why it did not work, i don't understand your last message and why sdcc accepts it. gcc rejects it and to my current understanding the compiler should reject it.
and
both define local data types which by that are different. (as gcc assures me.)
finally sdcc also rejects my code if i actually try to call the function pointer with a struct Data later:
never mind,
sdcc should not accept
I will check it.
Now sdcc revision #9578 rejects