要麼我是盲人,要麼沒有錯誤。我認爲這可能是第一選擇。請幫我找一根大海撈針。這是我的錯誤列表的一部分:錯誤:期望'='令牌和其他許多人的主要表達式
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;
}
我必須在整個代碼更多類似的錯誤,所以我覺得有東西就像缺少一些東西。你看到了嗎?我不。
是的!非常感謝!我知道這將是愚蠢的,但一個小時我找不到它。 :) – 2013-03-25 23:20:10
我想我現在應該抹掉這個話題,這對他人來說不是很有幫助的問題。它是否可行? – 2013-03-25 23:21:33
這完全取決於你。但是,保留主題通常會更好,以便我們可以將未來的主題標記爲重複項並鏈接到此處。事實上,這可能是它自己的重複,因爲我懷疑沒有人問過這樣的問題。 – 2013-03-25 23:22:18