This commit is contained in:
Andreas Rumpf 2019-05-25 07:33:33 +02:00 • committed by GitHub
commit 7e9cda7dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View file

@ -1837,9 +1837,9 @@ proc writeHeader(m: BModule) =
proc getCFile(m: BModule): AbsoluteFile = proc getCFile(m: BModule): AbsoluteFile =
let ext = let ext =
if m.compileToCpp: ".cpp" if m.compileToCpp: ".nim.cpp"
elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".m" elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".nim.m"
else: ".c" else: ".nim.c"
result = changeFileExt(completeCFilePath(m.config, withPackageName(m.config, m.cfilename)), ext) result = changeFileExt(completeCFilePath(m.config, withPackageName(m.config, m.cfilename)), ext)
when false: when false:

View file

@ -78,7 +78,7 @@ proc getCmd*(s: TSpec): string =
result = s.cmd result = s.cmd
const 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"] targetToCmd*: array[TTarget, string] = ["c", "cpp", "objc", "js"]
when not declared(parseCfgBool): when not declared(parseCfgBool):

View file

@ -0,0 +1,3 @@
int foo(int a, int b) {
return a+b;
}

View file

@ -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)