简体   繁体   English

cygwin和eclipse的sockets.h问题

[英]sockets.h problem with cygwin and eclipse

I keep getting this error: c:\\cygwin\\usr\\include/cygwin/socket.h:55:3: error: expected specifier-qualifier-list before '__uid32_t' 我不断收到此错误:c:\\ cygwin \\ usr \\ include / cygwin / socket.h:55:3:错误:'__uid32_t'之前的预期说明符-限定符列表

My code is mininmal and still can't compile: 我的代码很小,但仍然无法编译:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>

int main(void) {
    puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
    return EXIT_SUCCESS;
}

I have include C:\\cygwin\\usr\\include to compiler path and linker to C:\\cygwin\\usr\\lib 我将C:\\ cygwin \\ usr \\ include包含到编译器路径中,并将链接器链接到C:\\ cygwin \\ usr \\ lib

please advise 请指教

Headers under C:\\cygwin\\usr\\include , and libraries under C:\\cygwin\\usr\\lib , are for use in the Cygwin environment -- which means they should be referred to via their Cygwin paths, /usr/include and /usr/lib . C:\\cygwin\\usr\\include下的标头和C:\\cygwin\\usr\\lib均用于Cygwin环境中-这意味着应通过其Cygwin路径/usr/include/usr/lib来引用它们/usr/lib

I haven't used mingw, but I don't think it's part of Cygwin, and I wouldn't expect it to be able to use Cygwin's headers and libraries. 我没有使用过mingw,但是我不认为它是Cygwin的一部分,并且我不希望它能够使用Cygwin的标头和库。

If you're going to use mingw, you should use the headers and libraries that are installed with it. 如果要使用mingw,则应使用随它一起安装的标头和库。 Don't specify any Cygwin-related directories. 不要指定任何与Cygwin相关的目录。

Or you can use Cygwin's gcc (which is optional; you'll have to install it with setup.exe ). 或者,您可以使用Cygwin的gcc(这是可选的;您必须使用setup.exe安装它)。 In that case, you can run gcc or make from the command line. 在这种情况下,您可以从命令行运行gccmake I'm not sure whether Cygwin and Eclipse play nicely together. 我不确定Cygwin和Eclipse是否可以很好地配合使用。

I know this question is old, and I'm using a newer version, but I had a similar issue and it was resolved by moving #include <sys/socket.h> one line above #include <sys/types.h> . 我知道这个问题很旧,并且我正在使用较新的版本,但是我遇到了类似的问题,并且通过将#include <sys/socket.h>移到#include <sys/types.h>上方一行来解决。

Something in types.h appears to be blocking socket.h (not sure how). types.h中的某些内容似乎正在阻塞socket.h (不确定如何)。 Wish I had more details on the cause, but hope the solution helps some. 希望我能详细了解原因,但希望该解决方案能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM