Boost logo

Boost :

From: Boris Kolpackov (boris_at_[hidden])
Date: 2024-08-07 09:29:49


Daniela Engert via Boost <boost_at_[hidden]> writes:

> // module lib
> export module lib;
> #define BOOST_MODULE_EXPORT export
> #ifdef BOOST_xxx_ATTACHED_TO_GLOBAL_MODULE
> extern "C++" {
> #endif
> #include "internal.h"
> #ifdef BOOST_xxx_ATTACHED_TO_GLOBAL_MODULE
> }
> #endif

Are you aware of any substantial codebases that successfully use this
approach? Specifically, this idea of having a header that implements
both the header and module interfaces with the same source code and
which is then included in the module purview wrapped in extern "C++"?

Feels like there bound to be gotchas. For example, that header likely
includes other headers (is it ok to wrap a standard library headers
in extern "C++"?) and maybe even imports some modules (potentially
without even knowing that, for instance, via a third-party header).

BTW, we are in the process of considering what mechanisms we should
have in build2 for mixing modules/headers packages and I wrote some
thoughts on the possible approaches to implement such dual
header/modules support, in case anyone is interested:

https://github.com/build2/build2/issues/413#issuecomment-2272932212


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk