环境
- mcpp: 0.0.41
- 工具链: gcc@16.1.0 (xlings-fromsource)
- 系统: Fedora 44, x86_64
项目配置 (mcpp.toml)
[package]
name = "M3Lib"
version = "0.1.0"
[targets.M3Lib]
kind = "lib"
[lib]
path = "m3/m3.cppm"
[build]
sources = ["m3/**/*.cppm"]
cxxflags = ["-std=c++26", "-fcontracts"]
[toolchain]
default = "gcc@16.1.0"
实际输出
$ mcpp build
Resolving toolchain
Resolved gcc@16.1.0 → @mcpp/registry/data/xpkgs/xim-x-gcc/16.1.0/bin/g++
Compiling M3Lib v0.1.0 (.)
error: build failed
In module imported at /home/skyler/Dev/M3Lib/m3/detail/alignment_traits.cppm:5:1:
std: error: language dialect differs 'C++23', expected 'C++26/contracts'
std: error: failed to read compiled module: Bad file data
std: note: compiled module file is 'gcm.cache/std.gcm'
std: fatal error: returning to the gate for a mechanical issue
compilation terminated.
In module imported at /home/skyler/Dev/M3Lib/m3/detail/concepts.cppm:7:1:
std: error: language dialect differs 'C++23', expected 'C++26/contracts'
std: error: failed to read compiled module: Bad file data
std: note: compiled module file is 'gcm.cache/std.gcm'
std: fatal error: returning to the gate for a mechanical issue
compilation terminated.
补充信息
GCC 16.x 在 -std=c++26 下隐式启用 contracts:
$ g++ -std=c++26 -E -dM -x c++ - < /dev/null | grep contract
#define __cpp_contracts 202502L
-std=c++26 本身就会让方言变为 C++26/contracts,与 mcpp std 模块的 C++23 不匹配。
纯 C++23 项目(无 -std=c++26 和 -fcontracts)可以正常构建。
环境
项目配置 (mcpp.toml)
实际输出
补充信息
GCC 16.x 在
-std=c++26下隐式启用 contracts:-std=c++26本身就会让方言变为C++26/contracts,与 mcpp std 模块的C++23不匹配。纯 C++23 项目(无
-std=c++26和-fcontracts)可以正常构建。