- What language is this for? C++
- Which rule?
a combination of
cpp:S6018 - Use inline variables to declare this global variable
cpp:S5421 - Global variables should be const.
Why do you believe it’s a false-positive/false-negative?
i don’t know how to create a singleton that has a private destructor
- SonarQube - LTS version 9.9?
For example how to create a simple singleton struct like below that meets sonarqube c++ rules?
struct DeviceData {
// have to make it a singleton so that the WndProc method can access it
static auto Get() -> auto& {
static DeviceData singleton;
return singleton;
}
// Just some plain pointers
ID3D11Device* g_pd3dDevice{nullptr};
ID3D11DeviceContext* g_pd3dDeviceContext{nullptr};
IDXGISwapChain* g_pSwapChain{nullptr};
ID3D11RenderTargetView* g_mainRenderTargetView{nullptr};
private:
DeviceData() = default;
};