c - 错误 : expected '=' , ','、 ';'、 'asm' 或 '__attribute__' token 之前的 '*'

标签 c linux

我对 Unix 非常非常新,但在 C 方面有经验。我不确定这个消息是否适合 Unix 论坛(如果有的话)或 C。但是,因为它是一个编译错误,我觉得它最适合这里。

我对名为 ioquake3 的程序进行了“编译”。我收到这些错误。我试着用谷歌搜索它们。这些错误似乎是由双重包含或类似的原因引起的。 我无休止地尝试查看如何对代码进行写入编辑。但是,我无法修复它。

提前谢谢你。

代码:

#include <stdio.h>
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"

#ifdef WIN32
#define DEFAULT_CURL_LIB "libcurl-3.dll"
#elif defined(MACOS_X)
#define DEFAULT_CURL_LIB "libcurl.dylib"
#else
#define DEFAULT_CURL_LIB "libcurl.so.4"
#define ALTERNATE_CURL_LIB "libcurl.so.3"
#endif

#ifdef USE_LOCAL_HEADERS
  //#include &lt;../libcurl/curl/curl.h&gt;
#else
  //#include &lt;../libcurl/curl/curl.h&gt;
#endif


#ifdef USE_CURL_DLOPEN
extern char* (*qcurl_version)(void);
extern cvar_t *cl_cURLLib;
extern CURL* (*qcurl_easy_init)(void);
extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...);
`enter code here`extern CURLcode (*qcurl_easy_perform)(CURL *curl);
extern void (*qcurl_easy_cleanup)(CURL *curl);
extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
extern void (*qcurl_easy_reset)(CURL *curl);
extern const char *(*qcurl_easy_strerror)(CURLcode);

extern CURLM* (*qcurl_multi_init)(void);
extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle,
                        CURL *curl_handle);
extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle,
                        CURL *curl_handle);
extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle,
                        fd_set *read_fd_set,
                        fd_set *write_fd_set,
                        fd_set *exc_fd_set,
                        int *max_fd);
extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle,
                        int *running_handles);
extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle);
extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
                        int *msgs_in_queue);
extern const char *(*qcurl_multi_strerror)(CURLMcode);
#else
#define qcurl_version curl_version

#define qcurl_easy_init curl_easy_init
#define qcurl_easy_setopt curl_easy_setopt
#define qcurl_easy_perform curl_easy_perform
#define qcurl_easy_cleanup curl_easy_cleanup
#define qcurl_easy_getinfo curl_easy_getinfo
#define qcurl_easy_duphandle curl_easy_duphandle
#define qcurl_easy_reset curl_easy_reset
#define qcurl_easy_strerror curl_easy_strerror

#define qcurl_multi_init curl_multi_init
#define qcurl_multi_add_handle curl_multi_add_handle
#define qcurl_multi_remove_handle curl_multi_remove_handle
#define qcurl_multi_fdset curl_multi_fdset
#define qcurl_multi_perform curl_multi_perform
#define qcurl_multi_cleanup curl_multi_cleanup
#define qcurl_multi_info_read curl_multi_info_read
#define qcurl_multi_strerror curl_multi_strerror
#endif

qboolean CL_cURL_Init( void );
void CL_cURL_Shutdown( void );
void CL_cURL_BeginDownload( const char *localName, const char *remoteURL );
void CL_cURL_PerformDownload( void );
void CL_cURL_Cleanup( void );

错误:

make[2]: `build/release-linux-x86_64/ioq3ded.x86_64' is up to date.
CC code/client/cl_cgame.c
In file included from code/client/cl_cgame.c:24:
code/client/client.h:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
code/client/client.h:41: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:41: error: expected ')' before '*' token
code/client/client.h:42: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:42: error: expected ')' before '*' token
code/client/client.h:43: error: expected ')' before '*' token
code/client/client.h:44: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:44: error: expected ')' before '*' token
code/client/client.h:45: error: expected ')' before '*' token
code/client/client.h:46: warning: parameter names (without types) in function declaration
code/client/client.h:48: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
code/client/client.h:49: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:49: error: expected ')' before '*' token
code/client/client.h:51: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:51: error: expected ')' before '*' token
code/client/client.h:53: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:53: error: expected ')' before '*' token
code/client/client.h:58: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:58: error: expected ')' before '*' token
code/client/client.h:60: error: expected declaration specifiers or '...' before '*' token
code/client/client.h:60: error: expected ')' before '*' token
code/client/client.h:61: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
code/client/client.h:63: warning: parameter names (without types) in function declaration
In file included from code/client/cl_cgame.c:24:
code/client/client.h:264: error: expected specifier-qualifier-list before 'CURL'
code/client/cl_cgame.c: In function 'CL_GetServerCommand':
code/client/cl_cgame.c:276: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c: In function 'CL_InitCGame':
code/client/cl_cgame.c:751: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c: In function 'CL_CGameRendering':
code/client/cl_cgame.c:799: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c: In function 'CL_AdjustTimeDelta':
code/client/cl_cgame.c:834: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c: In function 'CL_FirstSnapshot':
code/client/cl_cgame.c:900: error: 'clientConnection_t' has no member named 'timeDemoBaseTime'
code/client/cl_cgame.c:919: error: 'clientConnection_t' has no member named 'speexInitialized'
code/client/cl_cgame.c:921: error: 'clientConnection_t' has no member named 'speexEncoderBits'
code/client/cl_cgame.c:922: error: 'clientConnection_t' has no member named 'speexEncoderBits'
code/client/cl_cgame.c:924: error: 'clientConnection_t' has no member named 'speexEncoder'
code/client/cl_cgame.c:926: error: 'clientConnection_t' has no member named 'speexEncoder'
code/client/cl_cgame.c:927: error: 'clientConnection_t' has no member named 'speexFrameSize'
code/client/cl_cgame.c:928: error: 'clientConnection_t' has no member named 'speexEncoder'
code/client/cl_cgame.c:929: error: 'clientConnection_t' has no member named 'speexSampleRate'
code/client/cl_cgame.c:931: error: 'clientConnection_t' has no member named 'speexPreprocessor'
code/client/cl_cgame.c:931: error: 'clientConnection_t' has no member named 'speexFrameSize'
code/client/cl_cgame.c:932: error: 'clientConnection_t' has no member named 'speexSampleRate'
code/client/cl_cgame.c:935: error: 'clientConnection_t' has no member named 'speexPreprocessor'
code/client/cl_cgame.c:939: error: 'clientConnection_t' has no member named 'speexPreprocessor'
code/client/cl_cgame.c:943: error: 'clientConnection_t' has no member named 'speexDecoderBits'
code/client/cl_cgame.c:944: error: 'clientConnection_t' has no member named 'speexDecoderBits'
code/client/cl_cgame.c:945: error: 'clientConnection_t' has no member named 'speexDecoder'
code/client/cl_cgame.c:946: error: 'clientConnection_t' has no member named 'voipIgnore'
code/client/cl_cgame.c:947: error: 'clientConnection_t' has no member named 'voipGain'
code/client/cl_cgame.c:949: error: 'clientConnection_t' has no member named 'speexInitialized'
code/client/cl_cgame.c:950: error: 'clientConnection_t' has no member named 'voipMuteAll'
code/client/cl_cgame.c:953: error: 'clientConnection_t' has no member named 'voipTarget1'
code/client/cl_cgame.c:953: error: 'clientConnection_t' has no member named 'voipTarget2'
code/client/cl_cgame.c:953: error: 'clientConnection_t' has no member named 'voipTarget3'
code/client/cl_cgame.c: In function 'CL_SetCGameTime':
code/client/cl_cgame.c:969: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c:972: error: 'clientConnection_t' has no member named 'firstDemoFrameSkipped'
code/client/cl_cgame.c:973: error: 'clientConnection_t' has no member named 'firstDemoFrameSkipped'
code/client/cl_cgame.c:1006: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c:1045: error: 'clientConnection_t' has no member named 'demoplaying'
code/client/cl_cgame.c:1061: error: 'clientConnection_t' has no member named 'timeDemoStart'
code/client/cl_cgame.c:1062: error: 'clientConnection_t' has no member named 'timeDemoStart'
code/client/cl_cgame.c:1062: error: 'clientConnection_t' has no member named 'timeDemoLastFrame'
code/client/cl_cgame.c:1063: error: 'clientConnection_t' has no member named 'timeDemoMinDuration'
code/client/cl_cgame.c:1064: error: 'clientConnection_t' has no member named 'timeDemoMaxDuration'
code/client/cl_cgame.c:1067: error: 'clientConnection_t' has no member named 'timeDemoLastFrame'
code/client/cl_cgame.c:1068: error: 'clientConnection_t' has no member named 'timeDemoLastFrame'
code/client/cl_cgame.c:1071: error: 'clientConnection_t' has no member named 'timeDemoFrames'
code/client/cl_cgame.c:1073: error: 'clientConnection_t' has no member named 'timeDemoMaxDuration'
code/client/cl_cgame.c:1074: error: 'clientConnection_t' has no member named 'timeDemoMaxDuration'
code/client/cl_cgame.c:1076: error: 'clientConnection_t' has no member named 'timeDemoMinDuration'
code/client/cl_cgame.c:1077: error: 'clientConnection_t' has no member named 'timeDemoMinDuration'
code/client/cl_cgame.c:1083: error: 'clientConnection_t' has no member named 'timeDemoDurations'
code/client/cl_cgame.c:1083: error: 'clientConnection_t' has no member named 'timeDemoFrames'
code/client/cl_cgame.c:1087: error: 'clientConnection_t' has no member named 'timeDemoFrames'
code/client/cl_cgame.c:1088: error: 'clientConnection_t' has no member named 'timeDemoBaseTime'
code/client/cl_cgame.c:1088: error: 'clientConnection_t' has no member named 'timeDemoFrames'
make[2]: *** [build/release-linux-x86_64/client/cl_cgame.o] Error 1
make[2]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/best_linux_20111012/ioquake3dev_clean'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/best_linux_20111012/ioquake3dev_clean'
make: *** [release] Error 2

C语言 Linux

最佳答案

gcc中,错误:

expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

通常与 typedef 相关联,当您使用它时,它不在范围内。例如下面的程序:

mytype fn(int n) { return (mytype)n; }
int main(void) { return 0; }

当你试图编译它时产生这个错误:

prog.c:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fn'

如果您在文件顶部插入 typedef int mytype; 行,它可以编译。

现在有点难以辨别代码中哪些精确行映射到错误中列出的行号,但我的第一个猜测是您没有包含 CURL 头文件。这似乎是你有这样的行的情况:

extern CURL* (*qcurl_easy_init)(void);

但是您似乎没有在任何地方包含可以为您提供 CURL 类型定义的头文件。

确实有以下代码:

#ifdef USE_LOCAL_HEADERS
  //#include &lt;../libcurl/curl/curl.h&gt;
#else
  //#include &lt;../libcurl/curl/curl.h&gt;
#endif

但这看起来像是您从网页的“查看源代码”表示中复制了这些内容,只是在它们不起作用时将它们注释掉了。您可能需要的是:

  #include <../libcurl/curl/curl.h>

当然,调整头文件的实际位置。

关于c - 错误 : expected '=' , ','、 ';'、 'asm' 或 '__attribute__' token 之前的 '*',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7763428/

相关文章:

linux - 如何将 Amazon EC2 Linux DISPLAY 指向我的 Macbook 上的 X11?

c - 使用命令行中的值形成字符数组并将其传递给其他函数

c - 如何使用 GTK+ 制作子窗口?

c++ - 共享库的动态链接或动态加载?

linux - 无法以普通用户身份运行docker

linux - 打开 RDB 文件失败...只读文件系统

c - 如何使用 C 从进程状态文件中获取 UID

c - 为什么 while 循环在 else 语句之前停止?

c++ - 仅使用位掩码确定偏移量

linux - 使用 find 命令但排除两个目录中的文件