[Issue 22332] ImportC: declarations in imported C files conflict with D declarations.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 24 06:14:40 UTC 2021


mipri <mipri at minimaltype.com> changed:

           What    |Removed                     |Added
                 CC|                            |mipri at minimaltype.com

--- Comment #1 from mipri <mipri at minimaltype.com> ---
This happens already with only D modules:

import std.uni, std.ascii;
enum x = 'x'.toUpper;

Error: function `std.ascii.toUpper!char.toUpper` at
/usr/include/dlang/dmd/std/ascii.d(697) conflicts with function
`std.uni.toUpper` at /usr/include/dlang/dmd/std/uni/package.d(9980)

Which can be resolved with selective imports or renamed imports or as such:

import std.uni, std.ascii;
enum x = std.ascii.toUpper('x');

In your case, stdio.printf("...") or core.stdc.stdio.printf("...")

The latter's a mouthful but you can fix that with a short name that you can
also require:

import stdio;
static import cio = core.stdc.stdio;

void main() {
    printf("this is from importC\n");
    cio.printf("Hello, world!\n");


More information about the Digitalmars-d-bugs mailing list