dmd icon indicating copy to clipboard operation
dmd copied to clipboard

WIP: Compare type sizes in druntime with ImportC

Open tim-dlang opened this issue 8 months ago • 3 comments

Types for bindings of C libraries in druntime need to match the C headers. Small differences can result in hard to debug problems.

This test tries to automatically find types with a wrong size. This is done by also getting type sizes from C headers using ImportC and comparing them. Differences between the sizes can have different reasons:

  • Bugs in ImportC (e.g. for bitfields) can result in a wrong size
  • Type definitions in druntime can be wrong
  • Different preprocessor options could be used, like _FILE_OFFSET_BITS
  • Size differences can be fine, because some structs contain a member for the size or a version

Members of structs and unions with the same name are also compared. For types with potential problems a comparison of the layout is printed.

tim-dlang avatar Jun 09 '24 14:06 tim-dlang