Reputation: 217
I currently am trying to pass a struct to a different file using a header file. It also gives me the warning "struct Connection’ declared inside parameter list". Three are three files, piggy1.h,piggg1.c, and ear.c. Any thoughts on why I can't get this code to compile? Thanks so much guys!
//piggy1.h----------------------------------------
void ear(struct Connection *connect1);
//-------------------------------------------------*
//ear.c --------------------------------------------
include "piggy1.h"
void ear(struct Connection *connect1){}
//---------------------------------------------------*
//piggy1.c -------------------------------------------
include "piggy1.h"
struct Connection{
int llport;
int rrport;
char rraddr[50];
int noleft;
int noright;
};
main(argc, argv)
int argc;
char *argv[];
{
int cases;
int noright = -1;
int noleft = -1;
int rraddr = -1;
int llport = -1;
int rrport = -1;
struct Connection connect;
}
Upvotes: 1
Views: 3811
Reputation: 1
Conflicting error means the parameters passes in your definition section and parameters passed in your declaration section do not match.
In your case, the error is shown because definition and declaration of ear function is done before the struct definition.
The compiler doesn't recognise your parameters and so an error is thrown.
Upvotes: 0
Reputation: 217
I defined the struct into the header file and this solved the problem! Place the following code into the header file.
struct Connection{
int llport;
int rrport;
char rraddr[50];
int noleft;
int noright;
};
Upvotes: 1