dmd icon indicating copy to clipboard operation
dmd copied to clipboard

ImportC: `typedef` C tag struct causes ImportC to emit erroneous "forward declared" struct definition.

Open LightBender opened this issue 9 months ago • 1 comments

The following struct in C:

//  bug.i
typedef struct tagTIME_STRUCT
{
        int   hour;
        int   minute;
        int   second;
} TIME_STRUCT;

Produces the following output snippet in ImportC in file bug.d:

...
	struct tagTIME_STRUCT
	{
		int hour = void;
		int minute = void;
		int second = void;
	}
	alias TIME_STRUCT = tagTIME_STRUCT;
	struct tagTIME_STRUCT;
...

The second "forward declared" struct declaration should never be present and causes a build error in DMD.

Command to get error: $dmd bug.i -Hf=bug.d -verrors=0 -main, compiling the resultant file then fails with duplicate struct tagTIME_STRUCT

LightBender avatar Feb 24 '25 00:02 LightBender

I can’t reproduce this bug.

drpriver avatar Apr 15 '25 02:04 drpriver