[Issue 24505] [REG2.108] ImportC: Function-like macros (newly translated to templates) may collide with regular symbols

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 15 20:12:28 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24505

Tim <tim.dlang at t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tim.dlang at t-online.de

--- Comment #1 from Tim <tim.dlang at t-online.de> ---
Maybe macros and normal symbols could be in different modules or mixin
templates, so one is used by default, but it is still possible to get the other
symbol explicitly. An example lowering could be:

```
struct stat { int x; };

void __stat(int x, int y);

mixin template __CMacros()
{
    // #define stat(x, y) __stat(x, y)
    void stat(T1, T2)(T1 x, T2 y)
    {
        __stat(x, y);
    }
}
mixin __CMacros!() __cmacros;
```

Now the compiler would prefer the struct, when using `stat`, but it would be
possible to get the macro using `__cmacros.stat`.

--


More information about the Digitalmars-d-bugs mailing list