Статические параметры в общей библиотеке в Windows не могут создавать и деконструировать как обычноC++

Программы на C++. Форум разработчиков
Anonymous
Статические параметры в общей библиотеке в Windows не могут создавать и деконструировать как обычно

Сообщение Anonymous »

Я пытаюсь создать статический параметр в библиотеке для использования в другом исполняемом файле, например:

Код: Выделить всё

//Library.h
#ifndef Library_H
#define Library_H

#include 
#include 

#ifdef _WIN32
#ifdef Build
#define Dll_Export_Import __declspec(dllexport)
#else
#define Dll_Export_Import
#endif
#else
#define Dll_Export_Import
#endif

class Dll_Export_Import Inner {
public:
Inner();

~Inner();

auto i() const -> int64_t;

private:
std::atomic_int64_t _i{0};
std::thread _thread{};
std::atomic_bool _finalized{false};
std::atomic_bool _stoped{false};
};

class Dll_Export_Import Library {
public:
static auto load() -> int64_t;

private:
static Inner _inner;
};
#undef Dll_Export_Import
#endif //Library_H

Код: Выделить всё

//Library.cpp
#include "Library.h"
#include "iostream"

Inner::Inner() {
std::cout 

Подробнее здесь: [url]https://stackoverflow.com/questions/78550717/static-params-in-shared-library-on-windows-cannot-construct-and-deconstruct-as-n[/url]

Вернуться в «C++»