Module import incompatibility

Steven Schveighoffer schveiguy at gmail.com
Tue Aug 31 14:09:01 UTC 2021


On 8/31/21 8:57 AM, frame wrote:
> On Tuesday, 31 August 2021 at 12:37:51 UTC, bauss wrote:
>> On Tuesday, 31 August 2021 at 12:26:28 UTC, frame wrote:
>>> I'm sure it was asked before but can't find the thread:
>>>
>>> How to deal best with an older library that uses the same class name 
>>> as module name?
>>> I get a lot of
>>>
>>> `Error: module ABC from file ...ABC.d must be imported with 'import 
>>> ABC'`
>>>
>>> Do I need to rename all modules?
>>
>> The problem is that the file doesn't have a module statement so the 
>> compiler tries to resolve the module name from the import but is 
>> unable to resolve that properly.
> 
> No, it has one, eg:
> 
> ```d
> module cairo.PdfSurface;
> ```
> 
> but the filename is PdfSurface.d and class name also :\
> 
> 

Are you sure this is the problem? `PdfSurface` is not a valid identifier 
here except for the class. In order to access the package, you need to 
use `cairo.PdfSurface`.

Tango was full of stuff like this, and it worked fine *as long as* it 
wasn't a top-level module.

-Steve


More information about the Digitalmars-d-learn mailing list