lcc icon indicating copy to clipboard operation
lcc copied to clipboard

constexpr is a reserved keyword in C23, can't be used as function name

Open NHOrus opened this issue 1 year ago • 3 comments

This causes lcc and some packages that bundle lcc to fail to compile with GCC-15

NHOrus avatar Mar 27 '25 19:03 NHOrus

confirmed; this is happening to me as well; it confuses Tree constexpr(int) function with C++/C23 keyword:

$ git clone https://github.com/drh/lcc.git

$ cd lcc

$ make all
cc -g -c -Isrc -o /main.o src/main.c                                                                                                                                                                                                                          
In file included from src/main.c:1:
src/c.h:516:1: error: ‘constexpr’ used with ‘extern’
  516 | extern Tree constexpr(int);
      | ^~~~~~
src/c.h:516:23: error: expected identifier or ‘(’ before ‘int’
  516 | extern Tree constexpr(int);
      |                       ^~~
make: *** [makefile:89: /main.o] Error 1                                                                                                                                                                                                                      

$ cc --version
cc (GCC) 15.1.1 20250425

$ make --version
GNU Make 4.4.1

$ uname -a
Linux MAL200424 6.15.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 10 Jun 2025 21:32:33 +0000 x86_64 GNU/Linux

$ git log -1
commit 2b5cf358d9aa6759923dd7461f2df7f7f2a28471 (HEAD -> master, origin/master, origin/HEAD)
Author: David R. Hanson <[email protected]>
Date:   Sat Oct 5 21:07:03 2024 -0600                                                                                                                                                                                                                                                                                                                                                                                             

sleeptightAnsiC avatar Jul 01 '25 17:07 sleeptightAnsiC

Changing the function name from constexpr to something else indeed fixed the problem for me.

scudo005 avatar Dec 05 '25 09:12 scudo005

or just pass -std=gnu99 or -std=c99 (if it works) to the build system in your CFLAGS or CC variables. tbh, having gcc15 default to c23 was quite a dick move, the standard wasn't even out of the printing press when they made it the new default. "go fast and break things" isn't really welcome in the C world.

rofl0r avatar Dec 05 '25 14:12 rofl0r