gpt4 book ai didi

C++ 宏 : how to create an overrite?

转载 作者:行者123 更新时间:2023-11-28 08:22:42 24 4
gpt4 key购买 nike

所以我发现需要使用像 Boost.Extension 这样的东西让我的应用程序对新模块更加开放。但是我一到 first tutorial我发现它的语法与我习惯的完全不同:

// Depending on the compiler and settings,
// it may be necessary to add a specific export
// declaration. The BOOST_EXTENSION_EXPORT_DECL
// adds this if necessary.
void BOOST_EXTENSION_EXPORT_DECL
boost_extension_hello_world(int repetitions) {
for (int i = 0; i < repetitions; ++i) {
std::cout << "Hello World" << std::endl;
}
}

我想让它成为可能写一些像 void function 而不是 void BOOST_EXTENSION_EXPORT_DECL 它看起来更好,因为我有 AS3 背景,它看起来不会像可怕的东西我。

那么如何为 C++ 宏创建覆盖,而不是在定义它的 header 中,而是在您自己的 C++ 文件中?

最佳答案

你可以只写以下内容:

#define function BOOST_EXTENSION_EXPORT_DECL

然后像这样声明函数:

void function
boost_extension_hello_world(int repetitions) {
for (int i = 0; i < repetitions; ++i) {
std::cout << "Hello World" << std::endl;
}
}

关于C++ 宏 : how to create an overrite?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5213188/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com