This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Struct Advance declaration ERROR C52

/** Advance Declaration **/
struct    enreg;
typedef   enreg Ts_Enreg;

/** Prototypes **/
extern unsigned char  MyFunc_1( Ts_Enreg * objects );
extern unsigned char  MyFunc_2( Ts_Enreg   objects[]);

MyFunc_1 and MyFunc_2 prototypes are equivalent, but C251 raises an error C52: Use of undefined type 'enreg'.

Why ?

C251 version : v5.58.17.0

PS : There is a complete description of the structure 'enreg' in the program source.

Arnaud

Parents
  • typedef   enreg Ts_Enreg;
    

    That doesn't do what you believe it does. It relies on there being a typedefed or #defined type 'enreg' present, but there isn't. If your textbook claims this is supposed to work, you need a different one, because the one you have is not actually about the C programming language.

    MyFunc_1 and MyFunc_2 prototypes are equivalent

    No, they're not. It's one thing to declare a function that takes an unknown type, but quite a different one if it takes a pointer to that unknown type.

Reply
  • typedef   enreg Ts_Enreg;
    

    That doesn't do what you believe it does. It relies on there being a typedefed or #defined type 'enreg' present, but there isn't. If your textbook claims this is supposed to work, you need a different one, because the one you have is not actually about the C programming language.

    MyFunc_1 and MyFunc_2 prototypes are equivalent

    No, they're not. It's one thing to declare a function that takes an unknown type, but quite a different one if it takes a pointer to that unknown type.

Children
No data