Open SuperSodaSea opened 6 months ago
v2.8.7+HEAD.da279272a
Windows 10 专业版 2004
当存在多个同名的 C++ 模块接口单元时,xmake 会编译成功,没有报错。
作为对比,CMake 会产生链接错误:
B.obj : error LNK2005: "int __cdecl f(void)" (?f@@YAHXZ::<!A>) 已经在 A.obj 中定义 ModuleTest.exe: fatal error LNK1169: 找到一个或多个多重定义的符号
个人认为 xmake 应该可以在依赖扫描阶段就发现模块重复定义,并报错。
xmake.lua
set_languages("c++20") target("ModuleTest") set_kind("binary") add_files("src/*.cpp", "src/*.mpp")
Main.cpp
#include <iostream> import A; int main() { std::cout << f() << std::endl; }
A.mpp
export module A; export int f() { return 1; }
B.mpp (与 A.mpp 内容相同)
除此之外还希望能够提前检测出模块分区重复定义,例如:
export module A; export import :B;
B.mpp
export module A:B; export int f();
B.cpp
module A:B; int f() { return 1; }
实际报错:
error: A.mpp A.mpp(3): error C7620: 无法导出模块分区 "B",它不是接口单元
可能会导致一些迷惑,所以希望这种情况也能在依赖扫描阶段识别出。
另附相关的 C++ 标准节选:
C++20 [module.unit]p2
A named module shall contain exactly one module interface unit with no module-partition, known as the primary module interface unit of the module; no diagnostic is required.
C++20 [module.unit]p3
A named module shall not contain multiple module partitions with the same module-partition.
虽然是 no diagnostic required,不过能有更友好的报错信息总是好的。
Bot detected the issue body's language is not English, translate it automatically. Title: C++ module interface will silently succeed when it is repeatedly defined.
Bot detected the issue body's language is not English, translate it automatically.
Title: C++ module interface will silently succeed when it is repeatedly defined.
Xmake 版本
v2.8.7+HEAD.da279272a
操作系统版本和架构
Windows 10 专业版 2004
描述问题
当存在多个同名的 C++ 模块接口单元时,xmake 会编译成功,没有报错。
期待的结果
作为对比,CMake 会产生链接错误:
个人认为 xmake 应该可以在依赖扫描阶段就发现模块重复定义,并报错。
工程配置
xmake.lua
Main.cpp
A.mpp
B.mpp (与 A.mpp 内容相同)
附加信息和错误日志
除此之外还希望能够提前检测出模块分区重复定义,例如:
A.mpp
B.mpp
B.cpp
实际报错:
可能会导致一些迷惑,所以希望这种情况也能在依赖扫描阶段识别出。
另附相关的 C++ 标准节选:
C++20 [module.unit]p2
C++20 [module.unit]p3
虽然是 no diagnostic required,不过能有更友好的报错信息总是好的。