gpt4 book ai didi

c++ - Microsoft 的 GCC 选项 init_priority 是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:37:23 28 4
gpt4 key购买 nike

在编译和链接 C++ 库或程序时,无法保证翻译单元之间静态 C++ 对象的初始化顺序。 GCC offers init_priority解决静态存档、共享对象和程序的问题:

init_priority (priority)

    In Standard C++, objects defined at namespace scope are guaranteed to
    be initialized in an order in strict accordance with that of their
    definitions in a given translation unit. No guarantee is made for
    initializations across translation units. However, GNU C++ allows
    users to control the order of initialization of objects defined at
    namespace scope with the init_priority attribute by specifying a
    relative priority, a constant integral expression currently bounded
    between 101 and 65535 inclusive. Lower numbers indicate a higher
    priority.

(静态存档似乎是最棘手的,因为它(大概)会被其他人链接)。

Microsoft 提供什么来控制翻译单元中静态 C++ 对象的初始化顺序?

最佳答案

#pragma init_seg可能是最相似的记录等效项。

关于c++ - Microsoft 的 GCC 选项 init_priority 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31899585/

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