Boost logo

Boost :

From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2024-07-08 06:32:01


воскресенье, 7 июля 2024 г. пользователь Daniela Engert via Boost <
boost_at_[hidden]> написал:
<...>

> If you as an author want to support mixing of both traditional #includes
> and module imports, then you'd better make sure that entity S is attached
> to the global module in both cases. Like along these lines:
>
> // 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
>
> This way, name attachment is a module compile-time option.
>
> I use this f.e. in my Asio module for a long time.

Does it make sense to go another way and make the header auto-import self
as a module if module exists:

// lib.h
#pragma once
#ifndef BOOST_NO_CXX20_MODULES
import lib;
#else
# ifndef BOOST_MODULE_EXPORT
# define BOOST_MODULE_EXPORT
# endif
# include "internal.h"
#endif

?

-- 
Best regards,
Antony Polukhin

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