-
Notifications
You must be signed in to change notification settings - Fork 326
Description
Just a few things that tripped me up while following along:
The functions ht_new and ht_del_hash_table are used in main.c but aren’t declared in hash_table.h. This causes an “implicit declaration” compiler error. Adding the declarations to the header file fixes it:
ht_hash_table* ht_new(void);
void ht_del_hash_table(ht_hash_table* ht);
The code uses strdup, which isn’t part of the C standard library by default — it’s POSIX. On some systems (like when compiling with gcc -Wall -Wextra -std=c99), you’ll get an “incompatible integer to pointer conversion” error unless you define the right macro. Adding this flag fixes it:
-D_POSIX_C_SOURCE=200809L
Might be worth adding a note that you need to compile both main.c and hash_table.c, like:
gcc -g -Wall -Wextra -D_POSIX_C_SOURCE=200809L main.c hash_table.c -o program
Hope this helps others avoid the same confusion. Cheers!