... | ... | @@ -296,7 +296,37 @@ TODO: Make sure this is still accurate after https://gitlab.haskell.org/ghc/ghc/ |
|
|
|
|
|
#### CPP preprocessing differences
|
|
|
|
|
|
TODO: If https://gitlab.haskell.org/ghc/ghc/-/issues/21668 is deemed not-a-bug, describe how to work around it.
|
|
|
Clang's preprocessor only implements a subset of the `-traditional-cpp` flag as compared to GCC's implementation of `-traditional-cpp`. As a result, you may experience preprocessor failures on GHC 9.4 on Windows if you include `#includes` in `{- ... -}` comments. For example:
|
|
|
|
|
|
```hs
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
module Foo where
|
|
|
|
|
|
{-
|
|
|
Here is some C code in a comment:
|
|
|
|
|
|
#include <stdio.h>
|
|
|
int main(void) {
|
|
|
printf("Hello, World!\n");
|
|
|
return 0;
|
|
|
}
|
|
|
-}
|
|
|
```
|
|
|
|
|
|
While this will compile on previous versions of GHC, which use GCC's preprocessor, it will not compile with GHC 9.4, as Clang will attempt to expand the commented-out `#include` directive, which confuses the compiler. This issue can be fixed by commenting the `#include` directive with `--` comments instead:
|
|
|
|
|
|
```hs
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
module Foo where
|
|
|
|
|
|
-- Here is some C code in a comment:
|
|
|
--
|
|
|
-- #include <stdio.h>
|
|
|
-- int main(void) {
|
|
|
-- printf("Hello, World!\n");
|
|
|
-- return 0;
|
|
|
-- }
|
|
|
```
|
|
|
|
|
|
---
|
|
|
|
... | ... | |