0

When I try to compile with

clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow crack.c -lcrypt -lcs50 -lm -o crack

I get

crack.c: error: implicit declaration of function 'crypt' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

I have in my source file, per the docs,

#define _XOPEN_SOURCE
#include <unistd.h>
1

The spec is perfectly correct. More than likely, you don't have

#define _XOPEN_SOURCE
#include <unistd.h>

At the very top of your program (ie, before any other #includes). If you move that to the top even above the other includes in your header, it will compile fine.

1
  • That's really weird. That works too, I guess something is was pulling in coreutils which was defining an alternative crypt() I had this below some other includes, but above my use of crypt() – Evan Carroll Jan 29 '19 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .