在OS X上使用crypt_r
我想在Mac OS X 10.8.2上使用crypt_r
函数
#define _GNU_SOURCE #include
产生
crypt.h: No such file or directory
我在哪里可以获得crypt.h文件? 还是我错了?
编辑问题 – 具体例子
#include #include int main(){ struct crypt_data * data = (struct crypt_data *) malloc(sizeof(struct crypt_data)); char * testhash; testhash = crypt_r("string", "sa", data); free(data); return 0; }
产生
gcc test.c -Wall test.c: In function 'main': test.c:5: error: invalid application of 'sizeof' to incomplete type 'struct crypt_data' test.c:7: warning: implicit declaration of function 'crypt_r' test.c:7: warning: assignment makes pointer from integer without a cast
编辑: crypt_r()
在OS X上不可用。
原始答案:
OS X上的
的内容由
处理。 所以,而不是
#define _GNU_SOURCE #include
简单地写
#include
为了访问crypt()
函数。