how to "include" the module file like C ?

lzzll ownrepos at gmail.com
Fri Apr 6 02:36:48 PDT 2012


Hi, I can auto index the module file use gcc,
but in D I must append the module file path to dmd args,
if I don't, dmd will give me an error like:
main.o: In function `_Dmain':
main.d:(.text._Dmain+0x15): undefined reference to `_D3lib1ai'
main.d:(.text._Dmain+0x2d): undefined reference to `_D3lib1ai'
collect2: ld returned 1 exit status
--- errorlevel 1

Here is the example:
//main.c
#include <stdio.h>
#include "lib.c"
int main(int argc, char** argv){
	printf("%d\n", a);
	a = 10;
	return 0;
}

//lib.c
int a = 1;

[pass] gcc main.c

//main.d
import std.stdio;
import lib;
int main(string[] args){
	writeln(lib.a);
	lib.a = 10;
	return 0;
}

//lib.d
int a = 1;

[pass] dmd main.d lib.d
[failed] dmd main.d
[failed] dmd main.d -inline
[failed] dmd main.d -I./
[failed] dmd main.d -I/full/path/

That mean I can't use geany to do the one key build when import 
the modules from file,
anybody known how to "include" the module file in D ?
Please teach me, thanks very much.


More information about the Digitalmars-d mailing list