[Issue 23290] New: Interfacing to C++ mention C++ symbols may have been stripped
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 9 14:06:45 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23290
Issue ID: 23290
Summary: Interfacing to C++ mention C++ symbols may have been
stripped
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dlang.org
Assignee: nobody at puremagic.com
Reporter: alphaglosined at gmail.com
When compiling against C++ object files, it is possible that the compiler has
stripped symbols out of the object file.
For instance, if you have the following code in a cpp file:
```c++
#include <iostream>
struct Foo
{
void print()
{
std::cout << "foo: " << a << ": hello from c++\n";
}
int a;
};
```
And try to link against it when compiling with ``clang -c`` it will result in
the linker error: ``undefined reference to 'Foo::print()'``.
This is worth mentioning in the docs for Interfacing to C++ page as it could be
a gotcha that can lead to people spinning their wheels (it was encountered by
someone on Discord).
--
More information about the Digitalmars-d-bugs
mailing list