Skip to content
New issue

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

`--cppCompileToNamespace:foo` fails compilation with `import os` #11194

Closed
kaushalmodi opened this issue May 7, 2019 · 1 comment

Comments

Projects
None yet
4 participants
@kaushalmodi
Copy link
Contributor

commented May 7, 2019

If the Nim project has import os, compilation with --cppCompileToNamespace:foo fails.

Example

# t.nim
import os

echo "a" / "b"

Compile above with:

nim cpp --cppCompileToNamespace:foo -r t.nim 

Current Output

/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:41:1: error: ‘NI’ does not name a type
 NI len;
 ^~
/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:42:1: error: ‘NI’ does not name a type
 NI reserved;
 ^~
/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:45:1: error: ‘NIM_CHAR’ does not name a type; did you mean ‘NIM_IMAN’?
 NIM_CHAR data[SEQ_DECL_SIZE];
 ^~~~~~~~
 NIM_IMAN
/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:47:9: error: ‘NU8’ does not name a type; did you mean ‘NULL’?
 typedef NU8 tyEnum_TNimKind_jIBKr1ejBgsfM33Kxw4j7A;
         ^~~
         NULL
/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:48:9: error: ‘NU8’ does not name a type; did you mean ‘NULL’?
 typedef NU8 tySet_tyEnum_TNimTypeFlag_v8QUszD1sWlSIWZz7mC4bQ;
         ^~~
         NULL
/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:49:71: error: ‘NI’ has not been declared
 typedef N_NIMCALL_PTR(void, tyProc_ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
                                                                       ^~
/tmp/kmodi/.cache/nim/t_d/stdlib_os.cpp:52:1: error: ‘NI’ does not name a type

Expected Output

a/b

Additional Information

> nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-05-06
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 2475d92c36e26e44372175c2cf4c21fbab084619
active boot switches: -d:release

@mratsim mratsim added the C++ codegen label May 7, 2019

@Araq Araq added the High Priority label May 8, 2019

@krux02 krux02 self-assigned this May 13, 2019

krux02 added a commit to krux02/Nim that referenced this issue May 13, 2019

krux02 added a commit to krux02/Nim that referenced this issue May 13, 2019

@krux02 krux02 referenced this issue May 13, 2019

Merged

fix #11194 #11242

@Araq Araq closed this in #11242 May 13, 2019

Araq added a commit that referenced this issue May 13, 2019

@kaushalmodi

This comment has been minimized.

Copy link
Contributor Author

commented May 14, 2019

I confirm the fix i.e. it compile and runs now.

Though .. I am failing to understand how --cppCompileToNamespace:foo actually works .. I compiled 2 projects to .so's that I plan to use in the same space, but they both still have NimMain (as I see using the nm utility on Linux.). I was expecting --cppCompileToNamespace:foo to allow creating unique "Nim mains". Is that not so?

E.g. nim cpp --cppCompileToNamespace:foo --app:lib -o:t.so t.nim creates t.so. And when I use nm on it, I get:

> nm t.so | grep '\bT [^_]'
0000000000014e91 T NimMain

I was expecting "foo" somewhere in that NimMain identifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.