Thread overview
[Issue 23402] importc function definitions from includes can cause D name conflicts
Nov 14, 2022
Lance Bachmeier
Dec 17, 2022
Iain Buclaw
Jan 12, 2023
Walter Bright
Jan 12, 2023
Lance Bachmeier
Apr 09, 2023
Walter Bright
Apr 10, 2023
Lance Bachmeier
Apr 13, 2023
Dlang Bot
Apr 13, 2023
Dlang Bot
November 14, 2022
https://issues.dlang.org/show_bug.cgi?id=23402

Lance Bachmeier <lance@lancebachmeier.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lance@lancebachmeier.com

--- Comment #1 from Lance Bachmeier <lance@lancebachmeier.com> ---
This causes a similar problem with enums. I'm getting error messages like this:

#defines(1378): Error: variable `arma_example.FP_NAN` conflicts with enum
member `__anonymous.FP_NAN` at /usr/include/math.h(936)

The error message is confusing, because (a) I don't define FP_NAN in my program, and (b) the error message itself doesn't make sense, as arma_example.FP_NAN and __anonymous.FP_NAN are not the same thing.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=23402

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
January 12, 2023
https://issues.dlang.org/show_bug.cgi?id=23402

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Can you boil it down to a compilable example, please?

--
January 12, 2023
https://issues.dlang.org/show_bug.cgi?id=23402

--- Comment #3 from Lance Bachmeier <lance@lancebachmeier.com> ---
(In reply to Walter Bright from comment #2)
> Can you boil it down to a compilable example, please?

This new bug covers mine (not Adam's). It might be specific to including
math.h.

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

A complete test case:

foo.c:

#include <math.h>

int main() {}

gcc foo.c -> compiles

dmd foo.c ->

#defines(797): Error: variable `foo.FP_NAN` conflicts with enum member
`__anonymous.FP_NAN` at /usr/include/math.h(855)
#defines(798): Error: variable `foo.FP_INFINITE` conflicts with enum member
`__anonymous.FP_INFINITE` at /usr/include/math.h(858)
#defines(799): Error: variable `foo.FP_ZERO` conflicts with enum member
`__anonymous.FP_ZERO` at /usr/include/math.h(861)
#defines(800): Error: variable `foo.FP_SUBNORMAL` conflicts with enum member
`__anonymous.FP_SUBNORMAL` at /usr/include/math.h(864)
#defines(801): Error: variable `foo.FP_NORMAL` conflicts with enum member
`__anonymous.FP_NORMAL` at /usr/include/math.h(867)

--
April 09, 2023
https://issues.dlang.org/show_bug.cgi?id=23402

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---

---- foo.c ------
#include <math.h>

int main() {}
---------

Now compiles without error. Though this has nothing to do with Adam's report.

--
April 10, 2023
https://issues.dlang.org/show_bug.cgi?id=23402

--- Comment #5 from Lance Bachmeier <lance@lancebachmeier.com> ---
(In reply to Walter Bright from comment #4)
> ---- foo.c ------
> #include <math.h>
> 
> int main() {}
> ---------
> 
> Now compiles without error. Though this has nothing to do with Adam's report.

Yes. My problem was fixed when you fixed this bug:

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

I originally thought it was related to Adam's report, but that turned out to be wrong.

--
April 13, 2023
https://issues.dlang.org/show_bug.cgi?id=23402

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15101 "fix Issue 23402 - importc function definitions from includes can caus…" fixing this issue:

- fix Issue 23402 - importc function definitions from includes can cause D name conflicts

https://github.com/dlang/dmd/pull/15101

--
April 13, 2023
https://issues.dlang.org/show_bug.cgi?id=23402

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15101 "fix Issue 23402 - importc function definitions from includes can caus…" was merged into master:

- e028af1fd9a9cf1d123e37447dfb91203b93ae40 by Walter Bright:
  fix Issue 23402 - importc function definitions from includes can cause D name
conflicts

https://github.com/dlang/dmd/pull/15101

--