Can't compile with 2 packages with the same name (in different modules)

Derek Parnell derek at psych.ward
Sun Mar 30 03:32:26 PDT 2008


On Sun, 30 Mar 2008 05:24:51 -0400, Alexandr wrote:

> Simen Kjaeraas Wrote:
>> Following the D module naming might be better, no?
>> i.e module1/myclass.d => module1.myclass.obj.
>> Of course, this might lead to problems with very long file names.
>> 
>> -- Simen

> can't understand you, be please more explicit

It might be a useful option for the D compiler to name the generated object
files based on the source file's package and module names. 


For instance if you have two source files of the same name but in different
directories, and thus in different packages, you could have 'module'
statements such as ...

 module package1.modulename;

in one source file and ...

 module package2.modulename;

in the other source file. Then the compiler could generate the object files
in a single output directory as ...

  package1.modulename.obj
  package2.modulename.obj

However this method is not problem free. One problem is that the object
file names could be longer than is currently done, and this could be an
issue for the command line and other buffer-size constraints in the linker
and executable file format. 

Another issue is that the 'module' statement is optional and often it is
omitted. The compiler would then do exactly as is done now ... create two
object files with the same name into the same directory. Maybe this could
be reduced if it uses the commandline file paths as 'package' names if a
module statement is missing???

  dmd package1/modulename.d package2/modulename.d 

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell


More information about the Digitalmars-d-learn mailing list