Compiling error in sys/socket.h

I'm doing some college work, and i came across this error when i compile:

1
2
3
4
5
6
7
8
9
10
g++ *.cpp -lpthread

In file included from Packet.cpp:2:
/usr/include/sys/socket.h:26: error: expected unqualified-id before string constant

In file included from ServerMain.cpp:3:
/usr/include/sys/socket.h:26: error: expected unqualified-id before string constant

In file included from ThreadData.cpp:2:
/usr/include/sys/socket.h:26: error: expected unqualified-id before string constant


I tried compiling with -lsocket and nothing changed.

ServerMain.cpp
has this include:

1
2
3
4
5
#include <pthread.h>
#include "typedefs.h"
#include <sys/socket.h>        /* API para sockets */
#include <arpa/inet.h>         /* Estrutura sockaddr */
#include <stdio.h> 


Other includes are similar to this one..

and the socket.h line 26 is this one:

__BEGIN_DECLS

and before this line, all there is is this:

1
2
3
4
5
6
#ifndef	_SYS_SOCKET_H
#define	_SYS_SOCKET_H	1

#include <features.h>

__BEGIN_DECLS


Problem is.. i never ever modified socket.h, and google got nothing about this error..


Anyone up for helping me?
Thanks.



My guess is that it is something you did in "typedefs.h".
Oh well... i don't see anything wrong with this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#define MAXPENDING 10
#define BUFSIZE 516
#define MAX_TRIES 5

typedef unsigned short uint16;

enum packetType
{
	NONE,
	RRQ,
	WRQ,
	DATA,
	ACK,
	ERROR,
}


but i could be wrong
:X
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define MAXPENDING 10
#define BUFSIZE 516
#define MAX_TRIES 5

typedef unsigned short uint16;

enum packetType
{
	NONE,
	RRQ,
	WRQ,
	DATA,
	ACK,
	ERROR  // no trailing comma
};  // you forgot your semicolon -- which caused the problem

Hope this helps.
Yep it worked, but tons of other errors showed up in my code..

Haha, thanks!
:D
Topic archived. No new replies allowed.