Closed
Description
Your environment
Which OS do you use?
Ubuntu
Which version of GHC do you use and how did you install it?
GHC 9.2.3, installed through ghcup
How is your project built (alternative: link to the project)?
cabal.project.local
:
ignore-project: False
profiling: True
executable-profiling: True
flags: -dynamic
Steps to reproduce
Checkout master, run cabal build exe:haskell-language-server
Expected behaviour
It should compiles
Actual behaviour
<command-line>: error: expected identifier or ‘(’ before numeric constant
`gcc' failed in phase `C Compiler'. (Exit code: 1)
Reason
Dig into the actual gcc
command issued by ghc --make
, we see:
-Xpreprocessor -Drename
But in <stdio.h>
, there already exists a function called rename
: https://en.cppreference.com/w/c/io/rename
So this finally lead to this line in the preprocessed C file (because rename
is replaced by 1
)
extern int 1 (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));
Then of course C compilation fails
Solution
I recommend adding a prefix to all CPP definitions in haskell-language-server executable. For example change -Drename
to -Dhls_rename
.