summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-07-01 01:29:28 +0200
committerAraq <rumpf_a@web.de>2015-07-01 02:15:21 +0200
commit54a374a8285a3a3387bcf0d31bbca0946ed28d51 (patch)
tree27ed87bd0dc8ec0d676957e64144b44f9c8c2d56 /compiler
parent4afb8b8043ab4c92c3ac69da3f6b5fc0a136e41a (diff)
downloadNim-54a374a8285a3a3387bcf0d31bbca0946ed28d51.tar.gz
.header pragma now supports preprocessor directives
Diffstat (limited to 'compiler')
-rw-r--r--compiler/cgen.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 390150cf7..f4854c988 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -610,10 +610,12 @@ proc generateHeaders(m: BModule) =
   add(m.s[cfsHeaders], tnl & "#include \"nimbase.h\"" & tnl)
   var it = PStrEntry(m.headerFiles.head)
   while it != nil:
-    if it.data[0] notin {'\"', '<'}:
-      addf(m.s[cfsHeaders], "$N#include \"$1\"$N", [rope(it.data)])
+    if it.data[0] == '#':
+      add(m.s[cfsHeaders], rope(it.data.replace('`', '"') & tnl))
+    elif it.data[0] notin {'\"', '<'}:
+      addf(m.s[cfsHeaders], "#include \"$1\"$N", [rope(it.data)])
     else:
-      addf(m.s[cfsHeaders], "$N#include $1$N", [rope(it.data)])
+      addf(m.s[cfsHeaders], "#include $1$N", [rope(it.data)])
     it = PStrEntry(it.next)
 
 proc retIsNotVoid(s: PSym): bool =
@@ -814,7 +816,7 @@ proc genVarPrototype(m: BModule, sym: PSym) =
   genVarPrototypeAux(m, sym)
 
 proc addIntTypes(result: var Rope) {.inline.} =
-  addf(result, "#define NIM_INTBITS $1", [
+  addf(result, "#define NIM_INTBITS $1" & tnl, [
     platform.CPU[targetCPU].intSize.rope])
 
 proc getCopyright(cfile: string): Rope =