[build2] Constraining the C++ standard

Boris Kolpackov boris at codesynthesis.com
Thu Jul 6 15:05:39 UTC 2023


lyrahgames via users <users at build2.org> writes:

> I constrained the standard to C++14 with 'cxx.std = c++14' in the
> 'root.build' of the tests package.

This should be:

cxx.std = 14


> The header-only library package itself still sets 'cxx.std = latest' to not
> constrain anything else. As the tests will never be a dependency of any
> other project, I thougt this should be ok.

It's not ideal but probably ok. It's not ideal because the library is
tested with the standard other than what it will be used with.


> However, building on Windows with MSVC the builds fail already in the
> configuration step with the compiler complaining about an unsupported
> C++ standard 'C++c++14':
>
> "error: C++c++14 is not supported by Microsoft (R) C/C++ Optimizing Compiler
> Version 19.36.32534 for x64"

That's because you've specified c++14 rather than 14 in cxx.std.


> Also, what should I do if a library that is not binless only compiles
> with a specific older standard but not with the latest one, as it is
> for ChaiScript:
> 
> https://github.com/build2-packaging/chaiscript
>
> As I got it from the manual, there might be ABI-breaking changes between
> standards. For now, I constrained the standard to C++17 for ChaiScript as
> it was the only thing I could think of, still, constraining the builds to
> GCC and Clang and possibly breaking ABI across different projects.

Yeah, I don't think there is anything else you can do about this (other
that dropping the library altogether). Maybe add a warning to the README
that the library is always built with C++17 and whether it will work in
a mixed-standard environment is anyones' guess.



More information about the users mailing list