C++ Logo

sg15

Advanced search

Re: [isocpp-core] Named modules, macros, and re-exporting header units

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Sun, 18 Dec 2022 03:19:04 +0000
[Jens]
> This clearly refers to "translation units", and translation units are a phase 7 concept per [lex.phases] p7:
> "Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted
> into a token (5.6). The resulting tokens are syntactically and semantically analyzed and translated as a
> translation unit."

In that case, what is the difference between "translation units" and "translated translation units"?

> Please have a look whether you like my suggested resolution.

Looks good.

Thanks!

-- Gaby

-----Original Message-----
From: Jens Maurer <jens.maurer_at_[hidden]>
Sent: Friday, December 16, 2022 3:10 PM
To: core_at_[hidden]
Cc: Gabriel Dos Reis <gdr_at_[hidden]>; sg15_at_[hidden]
Subject: Re: [isocpp-core] Named modules, macros, and re-exporting header units



On 16/12/2022 18.58, Gabriel Dos Reis via Core wrote:
> In the SG15 telecon this morning, the issue of whether a named modules can bring in macros via re-exported header units was discussed.
>
> The issue is that the current specification of module-import-declaration: 10.3/7 <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%237&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JXA%2FH8R8Rc%2B%2Bwv%2Flk7SSdlT1ZCkEc3gMmbeErK40GsY%3D&reserved=0>
>
>  
>
> When a /module-import-declaration/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23nt%3Amodule-import-declaration&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Drw10U5NHSaSH7c%2Bp4ACT6e1Xg%2Fcfqqc9l4tWFN4Beg%3D&reserved=0> imports a translation unit T, it also imports all translation units imported by exported /module-import-declaration/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23nt%3Amodule-import-declaration&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Drw10U5NHSaSH7c%2Bp4ACT6e1Xg%2Fcfqqc9l4tWFN4Beg%3D&reserved=0>/s/ in T; such translation units are said to be /exported/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23def%3Amodule%2Cexported&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=p%2BC2leTxAscvh%2Br%2FKgcN8yIJ26MSbcw7LewU5tJWzS4%3D&reserved=0> by T. <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%237.sentence-1&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6oGLyG5FkyVKw5VHnIisIknARB0UpfxdqfMrm8BFZyM%3D&reserved=0> Additionally, when a /module-import-declaration/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23nt%3Amodule-import-declaration&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Drw10U5NHSaSH7c%2Bp4ACT6e1Xg%2Fcfqqc9l4tWFN4Beg%3D&reserved=0> in a module unit of some module M imports another module unit U of M, it also imports all translation units imported by non-exported /module-import-declaration/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23nt%3Amodule-import-declaration&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Drw10U5NHSaSH7c%2Bp4ACT6e1Xg%2Fcfqqc9l4tWFN4Beg%3D&reserved=0>/s/ in the module unit purview of U. <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%237.sentence-2&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=iyciuamk2mwYerqRJ7J17XW%2F6kyBNfnhIEMY53JSXpQ%3D&reserved=0>91 <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23footnote-91&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Rnte24dDEYmtEMXN2yt5N0pwlZ0M9hkrnmRwCQ0fmdU%3D&reserved=0> These rules can in turn lead to
> the importation of yet more translation units. <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%237.sentence-3&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wKvR67AebWm2VfaboV84aa47YBCMPNqFcPsYe3TJwt8%3D&reserved=0>

This clearly refers to "translation units", and translation units are a phase 7 concept
per [lex.phases] p7:

"Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted
into a token (5.6). The resulting tokens are syntactically and semantically analyzed and translated as a
translation unit."

At that point, macros simply don't exist anymore.

I support adding examples and notes, but I feel there is nothing normatively amiss.

> places no restrictions on "it also imports all translation units imported by exported /module-import-declaration/ <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%23nt%3Amodule-import-declaration&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Drw10U5NHSaSH7c%2Bp4ACT6e1Xg%2Fcfqqc9l4tWFN4Beg%3D&reserved=0>/s/ in T;".
>
> It was pointed out that there is a CWG issue
>
>  
>
>     [cpp.import] Example should demonstrate that module imports do not import macros · Issue #199 · cplusplus/CWG · GitHub <https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcplusplus%2FCWG%2Fissues%2F199&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8c3x9vMlBd4ohrJhCycLm%2Fbj3TP26RIKKV2cFl1PSXg%3D&reserved=0>

This is not a CWG issue; it's a request that a CWG issue be created,
once the chair feels like it.

I felt like it:

https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcplusplus.github.io%2FCWG%2Fissues%2F2667.html&data=05%7C01%7Cgdr%40microsoft.com%7Cc050088f5f1f45af584e08dadfbaa98d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638068290045329737%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=zlU2hl7mQkI5dtwzxAdpYvnFJVBiwA3P628JmOgE3s8%3D&reserved=0

Please have a look whether you like my suggested resolution.

Jens

Received on 2022-12-18 03:19:08