-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Description
When I compile, I get the following warning:
$ make clean ; make
rm -rf smaz_test
gcc -o smaz_test -O2 -Wall -W -ansi -pedantic smaz.c smaz_test.c
smaz_test.c: In function ‘main’:
smaz_test.c:58:18: warning: implicit declaration of function ‘random’ [-Wimplicit-function-declaration]
ranlen = random() % 512;
The program compiles and the tests pass, so it looks like this warning is non-critical.
From looking around, I found an SO question/answer that offers a solution.
Adding the -D_XOPEN_SOURCE=600 option to gcc in the Makefile fixes the issue for me:
$ git diff
diff --git a/Makefile b/Makefile
index 62e8ccb..eecbac7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
all: smaz_test
smaz_test: smaz_test.c smaz.c
- gcc -o smaz_test -O2 -Wall -W -ansi -pedantic smaz.c smaz_test.c
+ gcc -D_XOPEN_SOURCE=600 -o smaz_test -O2 -Wall -W -ansi -pedantic smaz.c smaz_test.c
clean:
rm -rf smaz_test
My system information:
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Metadata
Metadata
Assignees
Labels
No labels