Hacker News new | ask | show | jobs
by jjnoakes 3274 days ago
> provided they don't make use of the few cases where C language features and C++ are no longer compatible, e.g. VLAs or structure initializers

Wouldn't one compile hiredis in C, their app in C++, and link the two together?

In general compiling C code with a C++ compiler isn't the path of least resistance.

1 comments

Depends how C++ compatible are the headers, as they can't make use of C99 or C11 features that aren't part of ANSI C++17.
True, although most C libraries ought to use those features in the implementation files and not the headers if they want to be used widely.

And even if some things leak into the headers they might be accepted by compiler extensions.

But yes, in general if a c library's headers are hostile to cross-language usage then using it from c++ won't be trivial.