C++ Logo

sg15

Advanced search

Re: P2898R0: Importable Headers are Not Universally Implementable

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Wed, 24 May 2023 20:07:24 +0200
On 24/05/2023 16.23, Daniel Ruoso wrote:
> Em ter., 23 de mai. de 2023 às 17:36, Jens Maurer
> <jens.maurer_at_[hidden]> escreveu:
>> In any case, I would really appreciate a very specific,
>> concrete example (exemplary source code) of the troubles
>> you seem to be talking about. If three two-line files
>> suffice to show the principles, that's good enough.
>> I have the gut feeling there is an assumption hidden somewhere
>> in your arguments that might not be universally shared.
>
> ```foo.h
> #ifdef FOO_ARG_1
> import <bar.h>
> #elif FOO_ARG_2
> import <baz.h>
> #endif
> ```
>
> ```qux.h
> #define FOO_ARG_1
> #include <foo.h>
> ```
>
> ```qux.cpp
> #include <qux.h>
> ```

Thanks for the example!

> Now, let's imagine that we declare `foo.h` to be an importable header.

And that's a user bug right there. foo.h is simply not supposed to
be treated as an importable header. You're welcome to attempt to
support such misguided code in your build system, but that does not
establish any argument at all that the feature "importable headers"
should be removed from the C++ standard.

Analogy: You can't divide by 0. That doesn't mean we should remove
0 from the set of valid integers, because 0 has plenty of good uses
elsewhere.

And for the avoidance of doubt: Absent substantially more
convincing rationale than examples such as the one above,
I'll strongly oppose a proposal attempting to remove the
"importable headers" feature from the C++ standard, including
encouraging CWG to form a disrupting consensus opinion in the
unlikely event that such a proposal would reach that stage.

Jens

Received on 2023-05-24 18:07:30