Kaitlyn
Kaitlyn

Reputation: 241

c compiler warning: 'struct x' declared inside parameter list

This question has been asked before, but none of the solutions seem to apply to my code. Here is my main file server.c:

#include <stdlib.h>
#include <unistd.h>
#include "message.h"

int main(int argc, char *argv[]) {
    // do stuff
    return 0;
}

And here is my included file message.c:

#include <stdlib.h>
#include <unistd.h>

struct message_t {
    int field1;
    int field2;
};

int sendMessage(struct message_t *message) {
    // do stuff
    return 0;
}

I also have a header file message.h:

#include <stdlib.h>
#include <unistd.h>

struct message_t {
    int field1;
    int field2;
};

int sendMessage(struct message_t *message);

When I compile server.c and message.c, I get this warning for message.c at the line where I declare sendMessage: warning: 'struct message_t' declared inside parameter list warning: its scope is only this definition or declaration, which is probably not what you want

What does it mean 'declared inside parameter list'? What is the parameter list it refers to?

Upvotes: 0

Views: 5011

Answers (1)

carmiac
carmiac

Reputation: 359

You are defining message_t in three places, when you should only define it in message.h. Also, message.c should include message.h.

Upvotes: 5

Related Questions