Open deech opened 4 years ago
shrug And for nim cpp
it can work out...
Just checked, it does the same thing if you set the backend to cpp
and change exportc
to exportcpp
.
It doesn't matter, if you use exportc
or emit
or header
there is a limit to what we can check before we hit the C compiler / linker. Eventually we have to trust that the programmer actually understands both C(++) and Nim for getting them work well together.
Sure I understand, but warning or erroring when trying to export any type signature that has a free type variable seems like it could save someone hours of scouring a big pile of generated C/C++. It's an easy mistake to make and a hard one to detect especially since if the generic is only instantiated once everything works fine.
If you try to compile the following file:
with the settings:
you get:
This is happening because
id
gets generated twice, once for theint
instantiation and once for thestring
. You can see this in the generated header:It should refuse to compile a generic function with
exportc
andcdecl
or should name the exported instantiations predictibly likeid_int
orid_string
.Nim version: