expected declaration specifiers or '...' before 'fd_set'

liushilei 2009-09-27 05:10:35
expected declaration specifiers or '...' before 'fd_set'

我编译c程序,和一个外部libcurl的a文件,就出这个错,是什么原因?
...全文
1298 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
奔跑的鳄鱼 2011-12-15
  • 打赏
  • 举报
回复
请问如何用g++编译?
CCWRSS 2011-11-30
  • 打赏
  • 举报
回复
试试用g++编译
qqcaoer 2011-05-21
  • 打赏
  • 举报
回复
其实这个还有一种可能性:
当a.h与b.h的头定义一样时,也会出现楼主的情况
即,a.h与b.h都有这样的定义:
#ifndef _A_H_
#define _A_H_
#endif
wenruimeng 2011-01-12
  • 打赏
  • 举报
回复
error: expected declaration specifiers or '...' before 这个错误是在Linux下面C语言的头文件包含问题产生的,如果a.h中#include b.h而b.h中的函数声明中用到了a.h中的结构体或者typedef,那么就会出现在包含b.h的时候a.h中的结构体或者typedef还没有声明,从而陷入错误,可以把结构体或者typedef移入到b.h就万事大吉了。
liushilei 2009-09-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 oyster2008 的回复:]
这个是编译错误啊,你贴下出错位置的代码
[/Quote]

#include <stdio.h>
#include <curl.h>
#include "com_android_example_JNI.h"

JNIEXPORT jlong JNICALL Java_com_android_example_JNI_getInfo(JNIEnv * e, jobject j){

return getinformation1();
}
long getinformation1(void)
{
CURL *curl;
CURLcode res;

long ct;

curl = curl_easy_init();

if(curl) {

curl_easy_setopt(curl, CURLOPT_URL, "http://svplayer.shooter.cn/api/pinreport.php");
//curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);

res = curl_easy_perform(curl);

if(CURLE_OK == res) {

res = curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&ct);

if((CURLE_OK == res)){
printf("CURLINFO_RESPONSE_CODE :%d\n", ct);

}
}

curl_easy_cleanup(curl);
return ct;
}
return 0;
}
oyster2008 2009-09-27
  • 打赏
  • 举报
回复
这个是编译错误啊,你贴下出错位置的代码
liushilei 2009-09-27
  • 打赏
  • 举报
回复
我的c程序,调用了外部libcurl的库,我想把他们打成so文件。
我把外部库的a文件和头文件都放在我程序中了,就出这个错了,这个错时报再外部库的h文件中,我想这个应该不是代码问题。是不是哪里链接有问题?
oyster2008 2009-09-27
  • 打赏
  • 举报
回复
代码

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧