Использование crypt_r на OS X

Я хочу использовать crypt_r функция в Mac OS X 10.8.2

#define _GNU_SOURCE
#include <crypt.h>

производит

crypt.h: No such file or directory

Где я могу получить файл crypt.h? Или я в том числе ошибаюсь?

Отредактированный вопрос - конкретный пример

#include <unistd.h>
#include <stdlib.h>

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

1 ответ

Решение

Редактировать: crypt_r() недоступно в OS X.

Оригинальный ответ:

Содержание <crypt.h> на OS X обрабатывается <unistd.h>, Итак, вместо

#define _GNU_SOURCE
#include <crypt.h>

просто пиши

#include <unistd.h>

для того, чтобы получить доступ к crypt() функция.

Другие вопросы по тегам