Ted Spradley
Ted Spradley

Reputation: 3436

TCPSocket.h:35: error: expected ',' or '...' before numeric constant

I'm receiving "TCPSocket.h:35: error: expected ',' or '...' before numeric constant" when compiling what I'm pretty sure was previously compiling code.

Line 35 is TCPSocket(int port, bool vOutput, const int DIRECTORY_SIZE);

from the below pasted class declaration

using namespace std;

class TCPSocket 
{
public:
#define SEND_BUFFER_LENGTH 80
#define DIRECTORY_SIZE 8192

    struct sockaddr_in myAddress, clientAddress;

    TCPSocket(int port, bool vOutput, const int DIRECTORY_SIZE);

    void buildTCPSocket(int newPort);
    void processMessage(char* bufferIn, int currentTCPSocket, int tcpSocket, bool verboseOutput);

    int getSocket1();
    int getSocket2();

Is either the define or the constructor definition an obvious error?

Edit: Ok, so for those of you reading years in the future, here is the corrected constructor declaration:

 TCPSocket(int port, bool vOutput);

Then, the defined DIRECTORY_SIZE was used in the constructor definition.

Upvotes: 1

Views: 2642

Answers (1)

Kiril Kirov
Kiril Kirov

Reputation: 38163

You can't do this:

TCPSocket(int port, bool vOutput, const int DIRECTORY_SIZE);

because it means

TCPSocket(int port, bool vOutput, const int 8192);

and this is not legal syntax. I guess you mean:

TCPSocket(int port, bool vOutput, const int nSize = DIRECTORY_SIZE);  

Upvotes: 7

Related Questions