Commit dc7a7fe
committed
module: make NEED_MODULE self contained again
register_<Module> is extern "C" so C and D hosts can call it unmangled
between das_initialize_modules() and das_initialize_finalize(). Two side
effects of that linkage broke every C++ host that pulls modules.
The macro can no longer declare the entry point: it expands inside a function
body, a linkage specification is only valid at namespace scope, and declaring
it without one names a different, C++ mangled symbol that nothing defines. So
each host had to add a file scope DECLARE_MODULE per module, boilerplate the
macro already has the name for. REGISTER_MODULE and
REGISTER_MODULE_IN_NAMESPACE now also emit das_pull_<Module>, a C++ linkage
tail call to register_<Module>, and NEED_MODULE declares that instead, which
at block scope is both legal and correct.
The macro also stopped ending in a semicolon, so two bare uses on consecutive
lines spliced into one expression and the second leading * became a
multiplication:
error: invalid operands to binary expression ('unsigned int' and
'DasThreadLocal<unsigned int, ...>')
Put the semicolon back. A call site that writes its own gets an empty
statement.
Pulling a module from C++ needs no declaration again:
void pull_game_das() {
NEED_MODULE(SomeModule)
}
The C side is untouched: register_<Module> and jit_register_<Module> keep C
linkage and their unmangled names, so the C API embedding flow works exactly
as documented. DECLARE_MODULE and PULL_MODULE keep working for callers that
would rather declare at file scope.1 parent 70e34f4 commit dc7a7fe
2 files changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1303 | 1303 | | |
1304 | 1304 | | |
1305 | 1305 | | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1306 | 1309 | | |
1307 | 1310 | | |
1308 | 1311 | | |
| |||
1333 | 1336 | | |
1334 | 1337 | | |
1335 | 1338 | | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1336 | 1342 | | |
1337 | 1343 | | |
1338 | 1344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
0 commit comments