Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile urweb.c with gcc 11.1 #239

Open
apple314159 opened this issue Sep 27, 2021 · 3 comments
Open

Failed to compile urweb.c with gcc 11.1 #239

apple314159 opened this issue Sep 27, 2021 · 3 comments

Comments

@apple314159
Copy link

Use of the local variable names true and false causes conflict with stdbool.h.
Easiest solution is to rename them _true and _false.

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../include/urweb -I./../../include/urweb -Wall -Wunused-parameter -Werror -Wno-format-security -Wno-deprecated-declarations -U_FORTIFY_SOURCE -pthread -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -MT urweb.lo -MD -MP -MF .deps/urweb.Tpo -c urweb.c -fPIC -DPIC -o .libs/urweb.o
In file included from /usr/include/unicode/utf8.h:37,
from urweb.c:23:
urweb.c: In function ‘uw_Basis_ensqlBool’:
urweb.c:3092:23: error: expected identifier or ‘(’ before numeric constant
3092 | static uw_Basis_int true = 1;
| ^~~~
urweb.c:3093:23: error: expected identifier or ‘(’ before numeric constant
3093 | static uw_Basis_int false = 0;
| ^~~~~
urweb.c:3096:20: error: lvalue required as unary ‘&’ operand
3096 | return (char *)&false;
| ^
urweb.c:3098:20: error: lvalue required as unary ‘&’ operand
3098 | return (char *)&true;
| ^
In file included from /usr/include/unicode/utf8.h:37,
from urweb.c:23:
urweb.c: In function ‘uw_Basis_stringToBool’:
urweb.c:3196:24: error: expected identifier or ‘(’ before numeric constant
3196 | static uw_Basis_bool true = uw_Basis_True;
| ^~~~
urweb.c:3197:24: error: expected identifier or ‘(’ before numeric constant
3197 | static uw_Basis_bool false = uw_Basis_False;
| ^~~~~
urweb.c:3200:12: error: lvalue required as unary ‘&’ operand
3200 | return &true;
| ^
urweb.c:3202:12: error: lvalue required as unary ‘&’ operand
3202 | return &false;
| ^
urweb.c: In function ‘uw_Basis_ensqlBool’:
urweb.c:3099:1: error: control reaches end of non-void function [-Werror=return-type]
3099 | }
| ^
urweb.c: In function ‘uw_Basis_stringToBool’:
urweb.c:3205:1: error: control reaches end of non-void function [-Werror=return-type]
3205 | }
| ^
cc1: all warnings being treated as errors

@achlipala
Copy link
Contributor

Thanks for catching that! I like your idea for a fix. Since you already have an environment set up to reproduce the issue, would you mind producing a PR that builds with GCC 11.1?

@vmsp
Copy link

vmsp commented Dec 29, 2021

Same thing is causing issues on macOS 11.6 with Apple Clang 13.0

@mdempsky
Copy link
Contributor

mdempsky commented Mar 6, 2022

I ran into the same issue trying to build urweb on Fedora 35. I used a similar workaround: renaming the local variables to true_ and false_.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants