Skip to content

Commit

Permalink
fixes #10299 (#11324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed May 25, 2019
1 parent 7e53c1c commit 7e9cda7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions compiler/cgen.nim
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion testament/specs.nim
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions tests/compilepragma/test.c
@@ -0,0 +1,3 @@
int foo(int a, int b) {
return a+b;
}
10 changes: 10 additions & 0 deletions 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)

0 comments on commit 7e9cda7

Please sign in to comment.