要么我失明,要么没有错误。我想这可能是第一选择。请帮我大海捞针。这是我的错误列表的一部分:
server.cpp: In function ‘int main(int, char**)’:
server.cpp:64:16: error: expected primary-expression before ‘=’ token
server.cpp:71:14: error: expected primary-expression before ‘=’ token
server.cpp:71:24: error: expected primary-expression before ‘)’ token
server.cpp:71:24: error: expected ‘;’ before ‘)’ token
server.cpp:72:12: error: expected primary-expression before ‘=’ token
server.cpp:80:10: error: expected primary-expression before ‘=’ token
make: *** [server] Error 1
这是我的代码的一部分:
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <netdb.h>
#include <iostream>
#include <regex.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <locale.h>
#include <cstring>
#include <signal.h>
#include <dirent.h>
using namespace std;
/* global variables */
// error codes
#define ERR_OK = 0;
#define ERR_PARAMS = 1;
#define ERR_SOCKET = 2;
#define ERR_BIND = 3;
#define ERR_OTHER = 99;
// others
#define LISTEN_BACKLOG 50
/* function prototypes */
void printErr(int EC);
int second(int port);
int main(int argc, char **argv)
{
int pflag = 0;
string pvalue;
int port;
int c;
opterr = 0;
while((c = getopt (argc, argv, "p:")) != -1) {
switch(c) {
case 'p':
pflag = 1;
pvalue.assign(optarg);
break;
case '?':
if(optopt == 'c')
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
else if(isprint (optopt))
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
return ERR_PARAMS;
default:
abort();
}
}
if(pflag == 0) {
printErr(ERR_PARAMS);
return ERR_PARAMS;
}
printf ("pvalue = %s\n", pvalue.c_str());
port = atoi(pvalue.c_str());
second(port);
return ERR_OK;
}
我在整个代码中还有更多类似的错误,所以我认为有一些东西就像缺少 collumn od 一样。你看到了吗?我不。