On Tuesday, 18 April 2023 at 20:05:05 UTC, DLearner wrote:
Is the declaration inside main not visible to the linker?

It affects the (fully qualified and mangled) name of the function. Compare:

```d
extern(C) void ExtCallee();
pragma(msg, ExtCallee.mangleof); /* ExtCallee (correct name) */
void main()
{
    extern(C) void ExtCallee();
pragma(msg, ExtCallee.mangleof); /* _D7ExtMain4mainFZ9ExtCalleeUZv (incorrect) */
}
```

I don't know the rationale behind that behavior, if there is one. Generally, just put your `extern(C)` prototypes in module scope.

Reply via email to