C++等效于C99外部直列__Attribute __(((ewnissy_ewanse_inline)))

发布于 2025-02-09 06:16:57 字数 730 浏览 2 评论 0原文

嗨,

我阅读 wiki 然后我意识到“ extern inline”在C99和C99和C99和C99和C ++。

例如:

foo.cpp

#include <stdio.h>

extern inline __attribute__((always_inline))
void test1(int b) {
    if (b) {
        printf("foo");
    }
}

void test2() {
    test1(0);
}

main.cpp

void test1(int);
void test2();

int main() {
    test1(0);
    test2();
}

i可以通过使用'-xc -std = c99'对G ++和Clang ++进行编译和链接。

但是,我确实需要一个C ++等同于此,有什么想法吗?

非常感谢。

PS当前的解决方法正在使用包装器功能,这不是优雅的。

Hi,

I read the wiki then I realized "extern inline" is different between C99 and C++.

For example:

foo.cpp

#include <stdio.h>

extern inline __attribute__((always_inline))
void test1(int b) {
    if (b) {
        printf("foo");
    }
}

void test2() {
    test1(0);
}

main.cpp

void test1(int);
void test2();

int main() {
    test1(0);
    test2();
}

I can compile and link them by using '-xc -std=c99' for g++ and clang++.

However, I do need a C++ equivalent of this, any idea?

Thank you very much.

P.S. The current workaround is using a wrapper function, which is not elegant.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文