C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Selectively pluck from header files

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 3 Jul 2024 11:20:35 -0400
On Wed, Jul 3, 2024 at 6:31 AM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Wednesday 3 July 2024 11:56:13 CEST Frederick Virchanza Gotham via Std-
> Proposals wrote:
> > But what if we could include
> > a header file, and only keep the macroes we need? Something like:
> >
> > #include <Windows.h> keep MAXPATH, APIENTRY
>
> Definitely not for #includes. Don't even go there. The preprocessor does not
> know about the C and C++ code that it is parsing so this could at worst
> extract macros, which is of very limited use in general scenarios.
>
> Instead, work with Modules. The import statement can be extended.

Of course, this makes little sense with modules because modules can't
export macros anyway. And the cost of a module import is not relative
to how much stuff is in it, so the only reason to want to import part
of a module is that the other parts of the module pollute the global
namespace or something. But that's a problem with how the module was
written.

Received on 2024-07-03 15:20:47