www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22312] New: importC: redundant typedefs are rejected


          Issue ID: 22312
           Summary: importC: redundant typedefs are rejected
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

The following trivial C code fails to compile:

// redundant.c
typedef int Integer;
typedef int Integer;

redundant.c(3): Error: alias `redundant.Integer` conflicts with alias
`redundant.Integer` at redundant.c(2)

Section 6.7.3 of C11 allows redundant typedefs to the same type.

This is problematic as at least on macOS there are types that are typedef’d
more than once in standard headers.

The following also ought to compile (but currently does not):

// redundant2.c
typedef int Integer;
typedef Integer Int;
typedef int Int;

Sep 17 2021