samtools / htslib

C library for high-throughput sequencing data formats
Other
784 stars 447 forks source link

Add C++ casts for external headers. #1683

Closed jkbonfield closed 9 months ago

jkbonfield commented 9 months ago

Klist.h and kseq.h use calloc, realloc and memchr in static inline code, but if we wish to permit our external headers to be used from a C++ include then these all need explicit casts as "void *" doesn't work the same in C++ as in C.

It's tempting to use extern "C" in an #ifdef __cplusplus guard, but the nature of these pseudo-template klib headers is such that the code will be expanded up later inside a C++ file so the extern "C" doesn't solve it.

See #1674 and #1682