DMD Refuses to Compile Multiple Source Files

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 17 20:25:42 PST 2017


On Wednesday, 18 January 2017 at 04:06:23 UTC, Samwise wrote:
> On Wednesday, 18 January 2017 at 03:51:50 UTC, ketmar wrote:
>> On Wednesday, 18 January 2017 at 03:37:46 UTC, Samwise wrote:
>>> extern int getReturnCode() {
>>> 	return 4;
>>> }
>>>
>>> still does not compile using the command from above. I may 
>>> very well be misunderstanding you though.
>>
>> yep. *both* prototype and real declaration should b
>> `extern(C)`. `(C)` part is important too!
>
> I have both the header in hello.d and the actual function in 
> getReturnCode.d as extern, and it still fails with the same 
> error.

extern(C), not simply extern. It turns off the name mangling. But 
really, the proper thing to do is to drop the prototype and 
import the module with the implementation. It's tge way modules 
are intended to be used. Unless you're doing something specidic 
like writing a library that calls an arbitrary user function.



More information about the Digitalmars-d-learn mailing list