summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2022-01-17 18:14:13 +0800
committerGitHub <noreply@github.com>2022-01-17 11:14:13 +0100
commit4f6b59de9698d0c29a2170ecc23c8d009b3181b7 (patch)
treed084e65daee82649989354688a646f710b5d6331
parent2c5b367001cc53859048d9adf450a5db3a949b92 (diff)
downloadNim-4f6b59de9698d0c29a2170ecc23c8d009b3181b7.tar.gz
mangle names in nimbase.h using cppDefine (#19395) [backport]
mangle names in nimbase.h
fix comments
-rw-r--r--config/config.nims5
-rw-r--r--tests/ccgbugs/tmangle.nim16
2 files changed, 21 insertions, 0 deletions
diff --git a/config/config.nims b/config/config.nims
index 893d6960f..88c344642 100644
--- a/config/config.nims
+++ b/config/config.nims
@@ -3,6 +3,11 @@
 cppDefine "errno"
 cppDefine "unix"
 
+# mangle the macro names in nimbase.h
+cppDefine "NAN_INFINITY"
+cppDefine "INF"
+cppDefine "NAN"
+
 when defined(nimStrictMode):
   # xxx add more flags here, and use `-d:nimStrictMode` in more contexts in CI.
 
diff --git a/tests/ccgbugs/tmangle.nim b/tests/ccgbugs/tmangle.nim
new file mode 100644
index 000000000..0050cef92
--- /dev/null
+++ b/tests/ccgbugs/tmangle.nim
@@ -0,0 +1,16 @@
+block:
+  proc hello() =
+    let NAN_INFINITY = 12
+    doAssert NAN_INFINITY == 12
+    let INF = "2.0"
+    doAssert INF == "2.0"
+    let NAN = 2.3
+    doAssert NAN == 2.3
+
+  hello()
+
+block:
+  proc hello(NAN: float) =
+    doAssert NAN == 2.0
+
+  hello(2.0)