Reading an environment variable value

Josh Holtrop jholtrop at gmail.com
Thu Jun 29 19:28:01 UTC 2023


On Thursday, 29 June 2023 at 19:19:21 UTC, Adam D Ruppe wrote:
> On Thursday, 29 June 2023 at 18:47:48 UTC, Josh Holtrop wrote:
>> $ ldc2 -of environment environment.d
>
> Since you named the file `environment.d` and didn't use an 
> explicit `module name.thing;` declaration, the compiler assumes 
> it should match the filename.
>
> So it injects an implicit `module environment;` to the top of 
> the file.
>
> Now when you mention `environment`, it uses *that* name instead 
> of the imported name, so it thinks you are trying to pass it 
> the module called environment instead of the object.
>
> If you add `module yourapp.environment;` or something to the 
> top it'd fix it (unless you tried to use something called 
> `yourapp`, then the name might conflict again!)
>
> or rename the file.

Ah, that makes sense, and yes that fixed it.

Thank you!


More information about the Digitalmars-d-learn mailing list