digitalmars.D.learn - Importing local modules in C style
- Binarydepth (6/6) Jun 25 2015 I want to import a module from my local project in C style
- Steven Schveighoffer (4/8) Jun 25 2015 What is your goal? Why doesn't D import work for you?
- Binarydepth (6/17) Jun 25 2015 I organize some exercises in some source files, it's more how I
- Steven Schveighoffer (5/22) Jun 25 2015 Well, if you publicly import the other module, it pulls all those public...
- jmh530 (8/11) Jun 25 2015 If the files are in the same folder, just import local; in the
- jmh530 (4/17) Jun 25 2015 Made a mistake. I was testing this with rdmd. rdmd main.d works
- Binarydepth (7/18) Aug 10 2015 No goal just wondering, Thanks!
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (6/8) Jun 26 2015 You can theoretically do this with `mixin(import("local.d"));`.
I want to import a module from my local project in C style (#include "local.h"). I know I can do "dmd main.d local.d" but I wonder if it can be done C style. Thank you BD
Jun 25 2015
On 6/25/15 9:57 AM, Binarydepth wrote:I want to import a module from my local project in C style (#include "local.h").No.I know I can do "dmd main.d local.d" but I wonder if it can be done C style.What is your goal? Why doesn't D import work for you? -Steve
Jun 25 2015
On Thursday, 25 June 2015 at 14:10:00 UTC, Steven Schveighoffer wrote:On 6/25/15 9:57 AM, 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. Thank you for your response StevenI want to import a module from my local project in C style (#include "local.h").No.I know I can do "dmd main.d local.d" but I wonder if it can be done C style.What is your goal? Why doesn't D import work for you? -Steve
Jun 25 2015
On 6/25/15 10:37 AM, Binarydepth wrote:On Thursday, 25 June 2015 at 14:10:00 UTC, Steven Schveighoffer wrote:Well, if you publicly import the other module, it pulls all those public symbols as if they were defined in the importing module. Perhaps this would work for you. -SteveOn 6/25/15 9:57 AM, 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.I want to import a module from my local project in C style (#include "local.h").No.I know I can do "dmd main.d local.d" but I wonder if it can be done C style.What is your goal? Why doesn't D import work for you? -Steve
Jun 25 2015
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.
Jun 25 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: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.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.
Jun 25 2015
On Thursday, 25 June 2015 at 14:10:00 UTC, Steven Schveighoffer wrote:On 6/25/15 9:57 AM, Binarydepth wrote:No goal just wondering, Thanks! In the future when GDC and MAKE can work together I want to just do "make code" and have the non-standard, custom libraries be supplied to the compiler by MAKE. For a project I would just write the Makefile for thisI want to import a module from my local project in C style (#include "local.h").No.I know I can do "dmd main.d local.d" but I wonder if it can be done C style.What is your goal? Why doesn't D import work for you? -Steve
Aug 10 2015
On Thursday, 25 June 2015 at 13:57:35 UTC, Binarydepth wrote:I want to import a module from my local project in C style (#include "local.h").You can theoretically do this with `mixin(import("local.d"));`. This will more or less copy-paste the content of local.d into the current scope. You also need to pass `-J.` to the compiler to allow it to read the file. But I would try to make it work with normal imports instead.
Jun 26 2015