0

I am getting this error within C.

error: expected ')' before '*' token

But cannot trace it.

void print_struct(struct_alias *s) //error within this line
{
...
} //end of print method

My question is when receiving this error where can the error stem back to? Is it a problem with the function, can it be an error with what is being passed in? What is the scope of the error?

Jebathon
  • 4,310
  • 14
  • 57
  • 108

2 Answers2

2

The compiler doesn't recognize the name struct_alias as a type name.

For that code to compile, struct_alias would have to be declared as a typedef, and that declaration would have to be visible to the compiler when it sees the definition of print_struct.

(Typedef names are tricky. In effect, they become temporarily user-defined keywords, which is why errors involving them can produce such confusing error messages.)

This is not specific to C89; it applies equally to C90 (which is exactly the same language as C89), to C99, and to C11.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
0

The error means that here's no such type as struct_alias declared in this translation unit.

AnT stands with Russia
  • 312,472
  • 42
  • 525
  • 765