94 Star 653 Fork 127

GVPtboox / xmake

 / 详情

c++20 module两个类相互依赖,xmake build卡8%

待办的
创建于  
2023-11-07 16:23
PS F:\cst_proj\cpp20> xmake build
[  0%]: generating.module.deps hh.a.cpp
[  0%]: generating.module.deps hh.b.cpp
[  0%]: generating.module.deps main.cpp
[  0%]: generating.module.deps hh.a.ixx
[  0%]: generating.module.deps hh.b.ixx
[  0%]: generating.module.deps hh.ixx
[  0%]: generating.module.deps hh.types.ixx
[  8%]: compiling.module.release hh:types
// hh.ixx
export module hh;
export import :a;
export import :b;
// hh.types.ixx
export module hh:types;
export class A;
export class B;
// hh.a.ixx
#include <iostream>

export module hh:a;

import :types;

export class A {
private:
	B* b = nullptr;
public:
	static void say() {
		std::cout << "A class" << std::endl;
	}
	int getInt() { return (int)'A'; }
	int getInt2();
};

export void say() {

}
// hh.a.cpp
module hh:a;
import :b;

int A::getInt2() {
	this->b = new B();
	this->b->getInt();
	return 100;
}
// hh.b.ixx
#include <memory>
export module hh:b;
import :types;

export class B {
private:
	A* a = nullptr;
public:
	int getInt();
};
// hh.b.cpp
#include <memory>
module hh:b;
import :a;

int B::getInt() {
	this->a = new A();
	this->a->getInt();
	return 100;
}
// main.cpp
#include <iostream>

import hh;

int main(int argc, char* argv) {
	std::cout << "ssss" << std::endl;
	B b;
	A a;
	std::cout << b.getInt() << a.getInt() << std::endl;
	return 0;
}
// xmake.lua
add_rules("mode.debug", "mode.release")

set_languages("c++20")

toolchain("clang17")
    set_kind("standalone")
    set_sdkdir("D:\\LLVM")
toolchain_end()

target("cpp20")
    set_kind("binary")
    add_files("*.cpp", "*.ixx")

评论 (0)

莫山山 创建了任务
莫山山 修改了描述
莫山山 修改了描述
展开全部操作日志

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
1251842 ysyashy 1578947407
Lua
1
https://gitee.com/tboox/xmake.git
git@gitee.com:tboox/xmake.git
tboox
xmake
xmake

搜索帮助