我在做一些Linux网络编程的时刻,为了这个,我自己做了便携我应该在库调用中使用我自己的typedefs吗?
typedef char int8;
typedef unsigned char uint8;
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
现在我在一个地步,我想要写一个经常使用的插座一些包装功能的一些typdefs功能。一个简短的例子是:
int32 rawSocketCreate(int* sockfd, int protocol) {
*sockfd = socket(AF_PACKET, SOCK_RAW, htons(protocol));
if (*sockfd == -1) {
printf("Error creating raw socket\n");
return -1;
}
return 0;
}
我现在的问题是:对于我的参数传递给库函数,我应该继续使用标准数据类型或者还用我自己的?
rawSocketCreate(int* sockfd, int protocol)
/* OR */
rawSocketCreate(int32* sockfd, int32 protocol)
你还好吧(意思是你自己)。因为你用标准类型输入它。 – 2014-08-29 08:46:30