C++ Logo

sg15

Advanced search

Re: [isocpp-ext] Can we expect that all C++ source files can have the same suffix?

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Wed, 20 Apr 2022 19:10:31 +0000
Yeah, I thought we were past the debate of insisting to encode information in the filename.

-- Gaby

-----Original Message-----
From: Daniel Ruoso <daniel_at_[hidden]>
Sent: Wednesday, April 20, 2022 11:33 AM
To: nico_at_josuttis.de
Cc: René Ferdinand Rivera Morell via Ext <ext_at_lists.isocpp.org>; ISO C++ Tooling Study Group <sg15_at_lists.isocpp.org>; Gabriel Dos Reis <gdr_at_microsoft.com>; Tom Honermann <tom_at_honermann.net>; Nathan Sidwell <nathan_at_acm.org>; Peter Dimov <pdimov_at_gmail.com>
Subject: Re: [isocpp-ext] [SG15] Can we expect that all C++ source files can have the same suffix?

Em qua., 20 de abr. de 2022 às 14:10, Nicolai Josuttis
<nico_at_[hidden]> escreveu:
> IMO a compiler should parse a C++ file while a build system should not have to do that.

For this to be possible, we'd need additional requirements that I
don't think are something folks are open to.

 1. You would need the module interface and implementation unit source
files to be named in a predictable way in your source tree, so you can
identify which modules you have in your tree without reading the
files.

 2. You would need the dependency information to be extractable
without the use of the preprocessor. Currently it is valid to have the
preprocessor interfering into what are the modules imported by other
modules. The only thing that is possible without a preprocessor is to
detect if this c++ source file has module code or not.

As long as we allow any file to produce any module, and as long as we
allow dependencies to depend on the preprocessor, there's no way for a
build system to do this correctly without doing the scanning in order
to assemble the build rules correctly.

The current state of affairs is that modules require a multi-pass system:

 1. scan the sources to find which modules are where and which modules
depend on which
 2. produce the binary interface units in topological order,
 3. proper compilation phase that consumes the binary interface units

While it's technically possible to have that work in a "one-line"
command, this approach will only work on the most trivial cases, and
it will break down so quickly that there's no point in trying to make
compilers support that feature.

IMHO, it makes more sense to just accept that C++ with modules is not
really viable without a proper build system.

daniel

Received on 2022-04-20 19:10:33