C99 compatibility of the ccc build detection tool

51 views
Skip to first unread message

Florian Weimer

unread,
Nov 25, 2022, 3:33:45 PM11/25/22
to lp_s...@googlegroups.com
Fedora still uses lpsolve 5.5.2.0, and while trying to build the
distribution with a strict(er) C99 compiler, I noticed a compatibility
issue. In a few places, main is defined without a return type, and this
implicit int language feature was removed for C99.

This patch fixes that:

diff --git a/lp_solve/ccc b/lp_solve/ccc
index 9b79cea7ee71536c..b1f761aab33345d4 100644
--- a/lp_solve/ccc
+++ b/lp_solve/ccc
@@ -6,7 +6,7 @@ c=$CC
>/tmp/platform.c
echo '#include <stdlib.h>'>>/tmp/platform.c
echo '#include <stdio.h>'>>/tmp/platform.c
-echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
+echo 'int main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
$c /tmp/platform.c -o /tmp/platform
PLATFORM=`/tmp/platform`
rm /tmp/platform /tmp/platform.c >/dev/null 2>&1
@@ -20,7 +20,7 @@ math=-lm
echo '#include <stdio.h>'>>/tmp/isnan.c
echo '#include <stdlib.h>'>>/tmp/isnan.c
echo '#include <math.h>'>>/tmp/isnan.c
-echo 'main(){isnan(0.0);}'>>/tmp/isnan.c
+echo 'int main(){isnan(0.0);}'>>/tmp/isnan.c
$c /tmp/isnan.c -o /tmp/isnan $math >/dev/null 2>&1
if [ $? = 0 ]
then NOISNAN=
diff --git a/lpsolve55/ccc b/lpsolve55/ccc
index 0470611bc45a851c..ca350f257add7730 100644
--- a/lpsolve55/ccc
+++ b/lpsolve55/ccc
@@ -6,7 +6,7 @@ c=$CC
>/tmp/platform.c
echo '#include <stdlib.h>'>>/tmp/platform.c
echo '#include <stdio.h>'>>/tmp/platform.c
-echo 'main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
+echo 'int main(){printf("ux%d", (int) (sizeof(void *)*8));}'>>/tmp/platform.c
$c /tmp/platform.c -o /tmp/platform
PLATFORM=`/tmp/platform`
rm /tmp/platform /tmp/platform.c >/dev/null 2>&1
@@ -18,7 +18,7 @@ mkdir bin bin/$PLATFORM >/dev/null 2>&1
echo '#include <stdio.h>'>>/tmp/isnan.c
echo '#include <stdlib.h>'>>/tmp/isnan.c
echo '#include <math.h>'>>/tmp/isnan.c
-echo 'main(){isnan(0.0);}'>>/tmp/isnan.c
+echo 'int main(){isnan(0.0);}'>>/tmp/isnan.c
$c /tmp/isnan.c -o /tmp/isnan $math >/dev/null 2>&1
if [ $? = 0 ]
then NOISNAN=

Thanks,
Florian

Peter Notebaert

unread,
Jun 27, 2023, 3:17:46 PM6/27/23
to lp_solve
There are alot more shell scripts with this issue. And not only should int be added to main but it must also return a value to be 100% complient.

I adapted all these scripts.

Reply all
Reply to author
Forward
0 new messages