We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the compile pragma to compile an Obj-C file doesn't work (at least not in the same way as inlining the Obj-C code using emit works).
compile
emit
Given two files (sample.nim and guts.m):
sample.nim
guts.m
{.compile: "guts.m" .} type Id {.importc: "id", header: "<Cocoa/Cocoa.h>", final.} = distinct int proc newGreeter: Id {.importobjc: "Greeter new", nodecl.} proc greet(self: Id, x, y: int) {.importobjc: "greet", nodecl.} var g = newGreeter() g.greet(12, 34)
#include <Cocoa/Cocoa.h> @interface Greeter:NSObject { } - (void)greet:(long)x y:(long)dummy; @end #include <stdio.h> @implementation Greeter - (void)greet:(long)x y:(long)dummy { printf("Hello, World!\n"); } @end #include <stdlib.h>
$ nim objc -r sample.nim Hint: used config file '/Users/matt/lib/Nim/config/nim.cfg' [Conf] Hint: system [Processing] Hint: sample [Processing] CC: guts CC: sample CC: stdlib_system Error: execution of an external compiler program 'clang -c -w -I/Users/matt/lib/Nim/lib -o /Users/matt/.cache/nim/sample_d/sample.m.o /Users/matt/.cache/nim/sample_d/sample.m' failed with exit code: 1 /Users/matt/.cache/nim/sample_d/sample.m:109:30: error: use of undeclared identifier 'Greeter'; did you mean 'kNeuter'? g_P5lmsTG5mYVhG5BJh5KFZQ = [Greeter new]; ^~~~~~~ kNeuter /System/Library/Frameworks/ApplicationServices.framework/Frameworks/SpeechSynthesis.framework/Headers/SpeechSynthesis.h:149:3: note: 'kNeuter' declared here kNeuter = 0, ^ 1 error generated.
Hello World!
It works if I include the Obj-C code using an emit like this:
{.emit: """ #include <Cocoa/Cocoa.h> @interface Greeter:NSObject { } - (void)greet:(long)x y:(long)dummy; @end #include <stdio.h> @implementation Greeter - (void)greet:(long)x y:(long)dummy { printf("Hello, World!\n"); } @end #include <stdlib.h> """.} type Id {.importc: "id", header: "<Cocoa/Cocoa.h>", final.} = distinct int proc newGreeter: Id {.importobjc: "Greeter new", nodecl.} proc greet(self: Id, x, y: int) {.importobjc: "greet", nodecl.} var g = newGreeter() g.greet(12, 34)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Using the
compile
pragma to compile an Obj-C file doesn't work (at least not in the same way as inlining the Obj-C code usingemit
works).Example
Given two files (
sample.nim
andguts.m
):Current Output
Expected Output
Additional Information
It works if I include the Obj-C code using an
emit
like this:The text was updated successfully, but these errors were encountered: