It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
我有我的机器的主机名。我使用gethostname()头文件中的<unistd.h>函数。我从here下载了<unistd.h>,但是当我尝试对其进行编译时,编译器报告以下错误:

"Cannot open include file: 'sys/cdefs.h': No such file or directory".


有什么问题?

最佳答案

据推测,您正在使用Windows或其他非POSIX平台。否则,<unistd.h>应该已经可用。

在这种情况下,您不能简单地下载并包含随机的Unix标头,并期望它们能够正常工作。您将需要使用Windows版本(在这种情况下,我认为是<Winsock2.h> gives that function),或使用类似Unix的环境,例如MinGW

10-04 14:39