[SAOC 2025] Improve importC Weekly Update #5

Hipreme msnmancini at hotmail.com
Mon Oct 27 20:47:37 UTC 2025


On Monday, 27 October 2025 at 20:16:31 UTC, Sergey wrote:
> On Monday, 27 October 2025 at 13:10:29 UTC, Emmanuel wrote:
>> I just tested a simple typedef enum code in a .c file and dmd 
>> compiles it for me.
>>
>> please what have you encountered with it that you want to be 
>> fixed?
>>
>> Thanks!
>
> I have a bigger code where I've tried to apply importC. And it 
> gave me errors regarding several parts of the enum definitions 
> that looked like that in the header:
> ```c
> typedef enum
> {
> 	kColorBlack,
> 	kColorWhite,
> 	kColorClear,
> 	kColorXOR
> } LCDSolidColor;
> ```
>
> In manually prepared code we've used:
> ```d
> enum LCDSolidColor {
> 	black,
> 	white,
> 	clear,
> 	xor
> }
> ```

Do not forget that enums in C works quite different than in C++. 
D's enum is much more akin to C++'s `enum class`.

A conversion of a C enum into D, would have actually done:
```d
enum {
   kColorBlack,
   kColorWhite,
   kColorClear,
   kColorXOR
}
```


More information about the Digitalmars-d mailing list