2012-04-19 59 views
1

誰能告訴我的頭文件用於u_shortu_char等:u_short的頭文件?

我已經看到它在sys/socket.h使用:

typedef u_char  sa_family_t; 

但是,當我用頭在我的程序,它給我錯誤:

1>c:\program files\microsoft visual studio 10.0\vc\include\sys\socket.h(52): 
error C2146: syntax error : missing ';' before identifier 'sa_family_t' 

我認爲解決方案是包含頭,但我不知道它是什麼頭!

+0

不是一個真正的Windows編碼器,但在Windows上的套接字標頭通常是Winsock2.h – phb 2012-04-19 08:13:28

+0

這是正確的,我可以弄清楚。 現在,當我編譯我的程序,它編譯成功,但給我以下錯誤,當我運行它: Module2.exe':Loaded'C:\ Documents and Settings \ jhap1 \ Desktop \ NW_Diagnose \ Module2 \ New Folder \ Module2 \ Debug \ Module2.exe',加載符號。 'Module2.exe':加載'C:\ WINNT \ system32 \ ntdll.dll',找不到或打開pdb文件 – bogusbonafide 2012-04-19 11:02:18

+0

如果我以管理員身份運行它,它的工作原理。 – bogusbonafide 2012-04-19 11:09:10

回答

0

Header file for u_short?

我們剛剛在不經常使用的平臺上進行了測試。我們遇到了類似的問題,在Cygwin i686下使用GCC 5.3和-std=c++11。該代碼已穩定約15年(給與否)。

我找不到標準標題。

Grepping在OS X和Linux顯示u_short是相當普遍的,即使有Cygwin的,現在下(2016年6月)0命中:

# Ununtu 
$ grep -IR "u_short" /usr/include | wc -l 
31 

# OS X 
$ grep -IR "u_short" /usr/include | wc -l 
122 

# Solaris 
$ /usr/gnu/bin/grep -IR "u_short" /usr/include/ | wc -l 
125 

和:

# Ubuntu 
$ grep -IR "u_short" /usr/include | grep typedef 
/usr/include/x86_64-linux-gnu/bits/types.h:typedef unsigned short int __u_short; 
/usr/include/x86_64-linux-gnu/sys/types.h:typedef __u_short u_short; 
/usr/include/rpc/types.h:typedef __u_short u_short; 
/usr/include/linux/coda.h:typedef unsigned short u_short; 

# OS X 
$ grep -IR "u_short" /usr/include | grep typedef 
/usr/include/netinet/ip_mroute.h:typedef u_short vifi_t;  /* type of a vif index */ 
/usr/include/netinet6/ip6_mroute.h:typedef u_short mifi_t;  /* type of a mif index */ 
/usr/include/sys/types.h:typedef unsigned short  u_short; 

# Solaris 
$ /usr/gnu/bin/grep -IR "u_short" /usr/include/ 2>/dev/null | grep typedef 
/usr/include/sys/types.h:typedef unsigned short u_short; 
/usr/include/rpcsvc/nfs_acl.h:typedef u_short o_mode; 

你應該是安全的轉換爲unsigned short或可能是uint16_t(在Unix和Linux上從<stdint.h>)而不是u_short