Clang.jl icon indicating copy to clipboard operation
Clang.jl copied to clipboard

Edge cases encountered while generating bindings for Hwloc

Open JBlaschke opened this issue 2 years ago • 1 comments

I am generating the bindings for Hwloc_jll, and I encountered a few edge cases that I thought you might like to know about -- all of these have straightforward workarounds, so this isn't urgent here.

  • hwloc.h uses INT_MAX:
#define HWLOC_TYPE_UNORDERED INT_MAX

requiring the inclusion of something like:

const INT_MAX = typemax(Int64)
  • hwloc.h defines:
#define HWLOC_UNKNOWN_INDEX (unsigned)-1

which Clang.jl translated to:

const HWLOC_UNKNOWN_INDEX = unsigned - 1 

I replaced this line with:

const HWLOC_UNKNOWN_INDEX = INT_MAX

instead.

  • Clang.jl also generated lines like:
const __HWLOC_HAVE_ATTRIBUTE_UNUSED = GXX_ABOVE_3_4 || GCC_ABOVE_2_95

However the constants on the RHS are defined as integers, eg:

const GXX_ABOVE_3_4 = 0
const GCC_ABOVE_2_95 = 1

and so on. A quick fix was to replace || with |.

JBlaschke avatar Nov 26 '22 21:11 JBlaschke

Thanks for the issue. Let's keep collecting those failure cases, so we can fix them in the next round of refactoring.

Gnimuc avatar Nov 27 '22 03:11 Gnimuc