Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: 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. Alright, so I misunderstood what ketmar was saying. His solution did work. I'm just not sure I understand what you are trying to say here: I've started using dub for things, and I've learned a lot since this thread. Anyway, thanks for the support with this everybody.
Re: DMD Refuses to Compile Multiple Source Files
Thanks loads. I got it working using those modules. ~Sam
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 23:12:15 UTC, Mike Parker wrote: (source files), then use the import statement to make the declarations in other modules. Sorry, this should read "make the implementations available to other modules".
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 19:28:20 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: 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. Alright, so I misunderstood what ketmar was saying. His solution did work. I'm just not sure I understand what you are trying to say here: But really, the proper thing to do is to drop the prototype and import the module with the implementation. This will still preserve my multiple source files, without worrying about the headers, right? Thanks, ~Sam Yes. Take a look at some random projects from code.dlang.org and look at the way they have laid out their modules and what they import and from where.
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote: 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. Alright, so I misunderstood what ketmar was saying. His solution did work. I'm just not sure I understand what you are trying to say here: But really, the proper thing to do is to drop the prototype and import the module with the implementation. This will still preserve my multiple source files, without worrying about the headers, right? Thanks, ~Sam
Re: DMD Refuses to Compile Multiple Source Files
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.
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 04:06:23 UTC, Samwise wrote: 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. nope. it works.
Re: DMD Refuses to Compile Multiple Source Files
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 be `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.
Re: DMD Refuses to Compile Multiple Source Files
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 be `extern(C)`. `(C)` part is important too!
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 03:25:47 UTC, Stefan Koch wrote: On Wednesday, 18 January 2017 at 03:11:08 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent solution. It would work, but still. I'm also not sure about the syntax for that (Given that getReturnCode.d is in the same directory as hello.d). ~Sam In extern (D) functions (which is the default) The module name is part of the mangled name. What you are trying to do would work , if the getReturnType would be extern(C). Without changing anything about the hello.d file from above, and the only change being adding the extern keyword to the getReturnValue.d like this: extern int getReturnCode() { return 4; } still does not compile using the command from above. I may very well be misunderstanding you though. I've not been doing this particularly long... ~Sam
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 03:11:08 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent solution. It would work, but still. I'm also not sure about the syntax for that (Given that getReturnCode.d is in the same directory as hello.d). ~Sam In extern (D) functions (which is the default) The module name is part of the mangled name. What you are trying to do would work , if the getReturnType would be extern(C).
Re: DMD Refuses to Compile Multiple Source Files
On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent solution. It would work, but still. I'm also not sure about the syntax for that (Given that getReturnCode.d is in the same directory as hello.d). ~Sam
Re: DMD Refuses to Compile Multiple Source Files
Import the source file containing the external function instead of writing that prototype. It should compile then.