[Git][ghc/ghc][wip/geekosaur/clarify-cpp-2] further explanations of CPP options
Brandon S. Allbery (@geekosaur)
gitlab at gitlab.haskell.org
Thu Oct 24 12:59:33 UTC 2024
Brandon S. Allbery pushed to branch wip/geekosaur/clarify-cpp-2 at Glasgow Haskell Compiler / GHC
Commits:
fdceb680 by brandon s allbery kf8nh at 2024-10-24T08:59:23-04:00
further explanations of CPP options
It was missing the ANSI "token pasting" behavior, which affects
users of -XMagicHash. It also explains why clang's -traditional
isn't sufficient for preprocessing Haskell code.
- - - - -
1 changed file:
- compiler/GHC/SysTools/Cpp.hs
Changes:
=====================================
compiler/GHC/SysTools/Cpp.hs
=====================================
@@ -72,17 +72,26 @@ Haskell source. This avoids the following situations:
* Errors due to an ANSI C preprocessor lexing the source and failing on
names with single quotes (TH quotes, ticked promoted constructors,
- names with primes in them).
-
- Both of those cases may be subtle: gcc and clang permit C++-style //
- comments in C code, and Data.Array and Data.Vector both export a //
- operator whose type is such that a removed "comment" may leave code that
- typechecks but does the wrong thing. Another example is that, since ANSI
- C permits long character constants, an expression involving multiple
- functions with primes in their names may not expand macros properly when
- they occur between the primed functions.
-
-Third special type of preprocessor for JavaScript was added laterly due to
+ names with primes in them);
+
+ * Errors due to ANSI "token pasting" semantics, which are triggered by
+ "#" characters (which affects code using -XMagicHash).
+
+All of those cases may be subtle: gcc and clang permit C++-style //
+comments in C code, and Data.Array and Data.Vector both export a //
+operator whose type is such that a removed "comment" may leave code that
+typechecks but does the wrong thing. Another example is that, since ANSI
+C permits long character constants, an expression involving multiple
+functions with primes in their names may not expand macros properly when
+they occur between the primed functions. Token pasting means # characters
+may be stripped and surrounding identifiers combined into single words.
+
+It should be noted that clang's -traditional doesn't disable // or token
+pasting; as a result, the ghc runtime installer tries very hard to find a
+gcc in order to use its preprocessor. If one can't be found, a programmer's
+only recourse is to use "-pgmP cpphs" (cpphs is on Hackage).
+
+A third special type of preprocessor for JavaScript was added later, due to
needing to keep JSDoc comments and multiline comments. Various third party
minifying software (for example, Google Closure Compiler) uses JSDoc
information to apply more strict rules to code reduction which results in
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fdceb6805eac924720867b1f899675d58d77522d
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fdceb6805eac924720867b1f899675d58d77522d
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241024/0a696e7b/attachment-0001.html>
More information about the ghc-commits
mailing list