Skip to content

[low priority] Display warning/error when importcpp used in cc mode #12002

@awr1

Description

@awr1
{.emit: """/*TYPESECTION*/
class Foo {
public:
  Foo(): x(5) {}
  Foo(float x_): x(x_) {}
  float x;
};
""".}

type Foo {.importcpp: "Foo", nodecl.} = object
  x: cfloat

This runs correctly in cpp mode, but doesn't in cc mode, which is to be expected, but the error is not straightforward:

Hint: used config file '/home/awr/Git/nim/config/nim.cfg' [Conf]
Hint: used config file '/home/awr/Git/nim/config/config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: cpp [Processing]
/home/awr/Development/nimtests/cpp.nim(11, 6) Hint: 'Foo' is declared but not used [XDeclaredButNotUsed]
Hint:  [Link]
/usr/bin/ld: /home/awr/.cache/nim/cpp_d/cpp.nim.cpp.o: in function `PreMain()':
cpp.nim.cpp:(.text+0x45): undefined reference to `systemDatInit000()'
/usr/bin/ld: cpp.nim.cpp:(.text+0x56): undefined reference to `systemInit000()'
/usr/bin/ld: /home/awr/Development/nimtests/cpp: hidden symbol `_Z13systemInit000v' isn't defined
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
Error: execution of an external program failed: 'g++   -o /home/awr/Development/nimtests/cpp  /home/awr/.cache/nim/cpp_d/stdlib_system.nim.c.o /home/awr/.cache/nim/cpp_d/cpp.nim.cpp.o    -ldl'

Also I find it curious is why g++ is getting shelled-out even though it should be calling the C compiler.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions