DMD v2.080.1 does compile the following code:
---
module test;
extern int xx(char v);
int xx(char v) { return 0; }
void main() {
}
---
In my opinion, it should not compile, because the function is both requested to be linked from an outside library and is implemented in the object file itself. This is a contradiction.
However, I may misunderstand.
Comment #1 by porton — 2019-01-24T18:43:35Z
Hm, it compiles in C with GCC 8.2.0-7ubuntu1 (after removal the module declaration), too. Weird.
Comment #2 by dfj1esp02 — 2019-01-25T08:53:54Z
C uses this idiom to maintain compatibility between function declarations in the header file and function definitions in the implementation file. When implementation includes the header, the compiler checks that declarations match definitions and can report a warning if they don't. Well, extern just allows to declare a function, and provide implementation elsewhere, not restricted where.