Importing local modules in C style

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 25 13:26:47 PDT 2015


On Thursday, 25 June 2015 at 17:20:46 UTC, jmh530 wrote:
> On Thursday, 25 June 2015 at 14:37:28 UTC, Binarydepth wrote:
>>
>> I organize some exercises in some source files, it's more how 
>> I like to work with C. I'm used to organize source files this 
>> way and I was wondering if this was possible with D.
>>
>
> If the files are in the same folder, just import local; in the 
> main.d file and then run dmd main.d from the command line. You 
> might need to ensure that there is only one main function.
>
> If the files are in different folders, you have to use a -I to 
> the folder that contains local.d.
>
> I would recommend familiarizing yourself with Dub. It may make 
> your life easier.

Made a mistake. I was testing this with rdmd. rdmd main.d works 
fine because it builds dependencies, but dmd main.d does not 
work. You need it like you had it before, dmd main.d local.d.


More information about the Digitalmars-d-learn mailing list