diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-05-25 07:33:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-25 07:33:33 +0200 |
commit | 7e9cda7dbaf20ee35b05e79f29e2bda7dfcf58c9 (patch) | |
tree | 17d3853d51cdcd6f6a39e4c38fbe1bbec5169215 | |
parent | 7e53c1c5c58c1db070cd430b5630aca9efdd04ef (diff) | |
download | Nim-7e9cda7dbaf20ee35b05e79f29e2bda7dfcf58c9.tar.gz |
fixes #10299 (#11324)
-rw-r--r-- | compiler/cgen.nim | 6 | ||||
-rw-r--r-- | testament/specs.nim | 2 | ||||
-rw-r--r-- | tests/compilepragma/test.c | 3 | ||||
-rw-r--r-- | tests/compilepragma/test.nim | 10 |
4 files changed, 17 insertions, 4 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index be155df8d..95f1ee9ae 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1837,9 +1837,9 @@ proc writeHeader(m: BModule) = proc getCFile(m: BModule): AbsoluteFile = let ext = - if m.compileToCpp: ".cpp" - elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".m" - else: ".c" + if m.compileToCpp: ".nim.cpp" + elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".nim.m" + else: ".nim.c" result = changeFileExt(completeCFilePath(m.config, withPackageName(m.config, m.cfilename)), ext) when false: diff --git a/testament/specs.nim b/testament/specs.nim index 11286ceab..4d09f438f 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -78,7 +78,7 @@ proc getCmd*(s: TSpec): string = result = s.cmd const - targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"] + targetToExt*: array[TTarget, string] = ["nim.c", "nim.cpp", "nim.m", "js"] targetToCmd*: array[TTarget, string] = ["c", "cpp", "objc", "js"] when not declared(parseCfgBool): diff --git a/tests/compilepragma/test.c b/tests/compilepragma/test.c new file mode 100644 index 000000000..fc0482e40 --- /dev/null +++ b/tests/compilepragma/test.c @@ -0,0 +1,3 @@ +int foo(int a, int b) { + return a+b; +} diff --git a/tests/compilepragma/test.nim b/tests/compilepragma/test.nim new file mode 100644 index 000000000..56087fa57 --- /dev/null +++ b/tests/compilepragma/test.nim @@ -0,0 +1,10 @@ +discard """ + output: '''44''' + joinable: "false" +""" + +{.compile: "test.c".} + +proc foo(a, b: cint): cint {.importc: "foo", cdecl.} + +echo foo(40, 4) |