# C Structure defined in H headers.

## Recommended Posts

I figured this was a stupid problem so i put it here in the beginners fourm. Im declaring a struct in an h file called userProfile. adminOperations.h now when I make pointer to it in differnt prototypes in the sockOperations.h file my compiler throws a fit. Now ive been having differnt issues with this header file all related to this struct I just wanted to see if any one had any ideas as to what im doing. I mean I do the exact same thing to the FD SET struct and it works. So im at a loss. Let me know if you guys see any thing. error message is: [Warning] "struct userProfile" declared inside parameter list [Warning] its scope is only this definition or declaration, which is probably not what you want [Warning] "struct userProfile" declared inside parameter list adminOperations.h its where i declare the userProfile Struct thats giving me the problems.
[source lang=c]
/*==============================================================================
==============================================================================*/

#define TAG 131

typedef struct userProfile
{
int lineInConnection;
int setupDone;
int userColor;
}userProfile;

int checkBuffer(SOCKET *clientSocket_PTR,char *recv_buffer_PTR);

#endif
/*------------------------------------------------------------------------------*/


This is the sock header thats having so much trouble
[source lang=c]
/*==============================================================================
==============================================================================*/
#ifndef SOCKOPERATIONS_H
#define SOCKOPERATIONS_H

#define MAXSOCKETS 5
#define MAX_BUFFER 6000
#define USEREXIT 449

int selectCheckOnListenSocket(struct fd_set *listenSocketSet_PTR,SOCKET *listenSocket_PTR,SOCKET *clientSocket_PTR,int *clientConnected_PTR,char *connectionMessage,struct userProfile *clientProfile_PTR);

int fdSetSetup(struct fd_set *SocketSet_PTR,SOCKET *Socket_PTR);

int selectCheckOnConnectedSocket(struct fd_set *clientSocketSet_PTR,SOCKET *clientSocket_PTR,char *recv_buffer_PTR);

int sendToSocket(SOCKET *clientSocket_PTR,char *recv_buffer_PTR);

int userExit(struct  userProfile *clientProfile_PTR,int *clientConnected_PTR,SOCKET *clientSocket_PTR,int closingConnection);

int clientSend(SOCKET *clientSocket_PTR,char *send_buffer_PTR);

#endif
/*------------------------------------------------------------------------------*/



##### Share on other sites
You don't actually include adminOperations.h in sockOperations.h.

##### Share on other sites
Just a quick note, the typedef allows you to omit the struct keyword when using the type, that is, you can write:

userProfile p;

struct userProfile p;

##### Share on other sites
No i dont include adminOperations.h in anything but sockOperations.c

Also Ive tried to use userProfile instead of saying struct userProfile because of the typedef and it still gives me the errors. :(

##### Share on other sites
Quote:
 No i dont include adminOperations.h in anything but sockOperations.c

As SiCrane pointed out, that's your problem. userProfile is defined in adminOperations.h, so if you don't include it, the compiler has no way of knowing what the struct looks like (this is also the reason for the typedef error).

That said, because you are only declaring pointers to the struct, you don't have to include adminOperations.h. You can use a forward declaration at the top of sockOperations.h:

struct userProfile;

If you also want to use a typedef, I think you should write:

struct userProfile;
typedef struct userProfile userProfile;

or something like that.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628379
• Total Posts
2982350

• 10
• 9
• 15
• 24
• 11