Scope of enum

DLearner bmqazwsx123 at gmail.com
Sun Jul 11 12:37:20 UTC 2021


On Sunday, 11 July 2021 at 12:01:27 UTC, jfondren wrote:
> On Sunday, 11 July 2021 at 10:58:58 UTC, DLearner wrote:
>> Is there a way of forcing DMD to extend the scope of `MemSiz` 
>> to include `k_mod`?
>>
>> Best regards
>
> ```
> $ cat k_mod.d
> import test01;
>
> ubyte[MemSiz] MemPool;
>
> $ cat test01.d
> enum MemSiz = 240;
>
> void main() {
>     import std.stdio, k_mod;
>     writeln(typeid(MemPool));
> }
>
> $ dmd test01.d k_mod.d
> $ ./test01
> ubyte[240]
> ```

Doesn't seem to work for me (Windows):
```
C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>type test01.d
//  test01.d

enum MemSiz  = 240;

void main() {

    import k_mod;
}


C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>type k_mod.d
// k_mod.d


ubyte[MemSiz]  MemPool;


C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>dmd -i test01.d 
k_mod.d
k_mod.d(4): Error: undefined identifier `MemSiz``
```


More information about the Digitalmars-d-learn mailing list