C++ Logo


Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 14 Apr 2022 00:41:42 +0300
On Wed, 13 Apr 2022 at 23:58, Nicolai Josuttis via Ext
<ext_at_[hidden]> wrote:
> I wonder whether the behavior of VC++ is standard conforming.

The wondering is ill-formed. The C++ standard requires no files, and
by extension no particular file extensions, and allows
for all imaginable variations thereof, all-files,
some-files+something-else, no-files-at-all, etc.. See [lex.phases]/7,
and the explanatory
"[Note 2 : Source files, translation units and translated translation
units need not necessarily be stored as files,
nor need there be any one-to-one correspondence between these entities
and any external representation. The
description is conceptual only, and does not specify any particular
implementation. — end note]"

The standard leaves it completely unspecified how you provide your
program source to your implementation, and
an implementation can decide any which way it likes to facilitate
that. And that's by design. If you have an online compiler,
it doesn't necessarily use any files. If you feed source code to
'intellisense' for analysis, it doesn't necessarily use any files.
There is a (albeit partial) C++ implementation inside Qt Creator, for
code analysis, and it doesn't use files. But nevertheless,
if an implementation decides that you need to feed in metadata about a
source unit via command-line options, it's perfectly
conforming to do so. Such as, by saying "for source code such-and-such
to be compiled so-and-so, pass /interface".

You can certainly propose recommendations to be given by SG15. But an
SC22 programming language standard cannot
mandate how the tooling-interfaces or user-interfaces of the
implementations of the language are implemented, that's out of the

Received on 2022-04-13 21:41:54