warning: ‘struct user_data_s’ declared inside parameter list

Viewed 77718

I'm getting this error:

transform.c:23: warning: ‘struct user_data_s’ declared inside parameter list
transform.c:23: warning: its scope is only this definition or declaration, which is probably not what you want

Which I think is because I have a struct that contains a struct.

This is what I am trying to do:

void f2(struct user_data_s* data) {
  printf("Number %i\n", data->L);
}

void f1(struct user_data_s* data) {
  printf("Number %i\n", data->L);
  f2(data);
}

The printf in f1 works, but the line

void f2(struct user_data_s* data) {

gives the error.

Does anyone know how I can fix this?

3 Answers

Another good reason to use typedef, which Linus/Linux choose to avoid.

Is it legitimate to declare a structure in function arguments list? If not, then why would the compiler think it's a structure definition?

Related