C++ Logo


Advanced search

Re: [std-proposals] Pragmas using multiple C++ standards within the same project

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 24 Nov 2022 22:30:31 -0800
On Thursday, 24 November 2022 20:59:36 PST Mehmet Kayaalp via Std-Proposals
> Current IDEs such as Microsoft’s Visual Studio comprise multiple C++
> compilers, each associated with a different ISO standard. I fail to
> understand why we don’t come up with a version “pragma” for each piece of
> code, indicating which compiler version should compile it to produce the
> intended assembler code (instead of compiling the entire set of codes with
> a single compiler). What would be the unsolvable problem for linkers to
> link those assembler codes produced by different versions of compilers?

The problem is that by the time the compiler sees the pragma, it's too late.
The compiler is already compiling.

What you're asking for is a buildsystem feature, such that they'd choose
different compilers or different options passed to those compilers based on some
criterion or criteria. And this is already solved: many buildsystems can scan
files' contents and apply options to it (I know CMake can).

So maybe all you're asking is a standard CMake module. I suggest you create
that and then see what can't be done with it and what's clumsy or missing.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2022-11-25 06:30:33