Skip to content

CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043)

Ben Gamari requested to merge wip/T22043 into master

This is a reversion and re-application of !9323 (closed) with various changes accounting for:

  • a few documentation issues I found during auditing
  • library design changes, as described in the CLC proposal
  • missing changelog entries
  • misnamed tests

Resolves #22701 (closed). Resolves #22700 (closed). Resolves #22699 (closed). Fixes #22043 (closed).

Original description

Previously, when using capi calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing -Wincompatible-pointer-types-discards-qualifiers warning.

Foreign.C.Types.ConstPtr newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning.

Fixes #22043 (closed)

Edited by Ben Gamari

Merge request reports