[PATCH RFC] libcpp, libstdc++: add __has_import builtin
Jason Merrill
jason@redhat.com
Sun Nov 17 15:58:18 GMT 2024
On 11/15/24 6:30 PM, Ville Voutilainen wrote:
> On Sat, 16 Nov 2024 at 01:12, Jason Merrill <jason@redhat.com> wrote:
>>
>> Does this seem like an interesting direction?
>>
>> -- 8< --
>>
>> A problem with coexistence of module std and the library headers is that
>> import and then #include tends to break (PR99000). But even with that
>> fixed, it might be useful to be able to test whether a module has been
>> imported. So, this patch implements __has_import, along the same lines as
>> __has_builtin and such.
>>
>> This does not test whether an import is available, which seems too variable
>> of a property; rather, it tests whether we've already seen an import in this
>> TU.
>
> Should it be named __seen_import? All those __has-things seem to be feature-tests,
> and this isn't. Or to put it another way, the __has-things query properties of the implementation,
> this builtin is for querying what has been encountered in the TU so far. That sounds like
> apples and oranges, right?
Yeah, you're probably right; __has_include comes before the #include,
this comes after the import, so we using __has for both could be misleading.
Jason
More information about the Libstdc++
mailing list