Packages and module import
Jacob Carlborg
doob at me.com
Tue Mar 20 21:08:24 UTC 2018
On 2018-03-19 18:29, Russel Winder wrote:
> I had assumed that a directory of modules was a package. So for
> example:
>
> A/a.d
> A/b.d
>
> were two modules in package A. Especially given there is a module
> statement at the beginning of each module:
>
> A/a.d has module A.a;
> A/b.d has module A.b;
>
> Now A.b needs to access something from A.a. I had assumed that the
> import should be fully qualified. So in A.b.d:
>
> import A.a: thing;
>
> This all works when building the library.
>
>
> ldc2 -of=Build/Release/libdvbv5_d.so -shared -defaultlib=phobos2-ldc Build/Release/source/libdvbv5_d/linux_dmx.o Build/Release/source/libdvbv5_d/dvb_v5_std.o Build/Release/source/libdvbv5_d/dvb_frontend.o Build/Release/source/libdvbv5_d/dvb_log.o Build/Release/source/libdvbv5_d/dvb_demux.o Build/Release/source/libdvbv5_d/dvb_fe.o Build/Release/source/libdvbv5_d/dvb_file.o Build/Release/source/libdvbv5_d/dvb_scan.o Build/Release/source/libdvbv5_d/dvb_sat.o -L-ldruntime-ldc
>
>
> However when trying to build the unit-tests:
>
>
> ldc2 -I=source -unittest --main -of=Build/Test/libdvbv5_d source/libdvbv5_d/linux_dmx.d source/libdvbv5_d/dvb_v5_std.d source/libdvbv5_d/dvb_frontend.d source/libdvbv5_d/dvb_log.d source/libdvbv5_d/dvb_demux.d source/libdvbv5_d/dvb_fe.d source/libdvbv5_d/dvb_file.d source/libdvbv5_d/dvb_scan.d source/libdvbv5_d/dvb_sat.d
> source/libdvbv5_d/dvb_demux.d(35): Error: module linux_dmx from file source/libdvbv5_d/linux_dmx.d must be imported with 'import linux_dmx;'
>
>
> Am I just missing something simple?
Not sure if this will help, but are you aware that DStep can add a
package to the module declaration using "--package"?
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list