Use [[maybe_unused]]
for parameters that are sometimes not used
Depending on preprocessor settings, certain parameters may or may not be used. Instead of casing to (void) when not used, it's easier to use C++17's [[maybe_unused]] attribute to express this.
This commit is contained in:
parent
58e93ddd19
commit
e0c4d14541
@ -645,7 +645,7 @@ Out Utf<32>::toUtf32(In begin, In end, Out output)
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename In>
|
||||
Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)
|
||||
Uint32 Utf<32>::decodeAnsi(In input, [[maybe_unused]] const std::locale& locale)
|
||||
{
|
||||
// On Windows, GCC's standard library (glibc++) has almost
|
||||
// no support for Unicode stuff. As a consequence, in this
|
||||
@ -656,8 +656,6 @@ Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)
|
||||
(defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
|
||||
!(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
|
||||
|
||||
(void)locale; // to avoid warnings
|
||||
|
||||
wchar_t character = 0;
|
||||
mbtowc(&character, &input, 1);
|
||||
return static_cast<Uint32>(character);
|
||||
@ -690,7 +688,7 @@ Uint32 Utf<32>::decodeWide(In input)
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
template <typename Out>
|
||||
Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale)
|
||||
Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, [[maybe_unused]] const std::locale& locale)
|
||||
{
|
||||
// On Windows, gcc's standard library (glibc++) has almost
|
||||
// no support for Unicode stuff. As a consequence, in this
|
||||
@ -701,8 +699,6 @@ Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const st
|
||||
(defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
|
||||
!(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
|
||||
|
||||
(void)locale; // to avoid warnings
|
||||
|
||||
char character = 0;
|
||||
if (wctomb(&character, static_cast<wchar_t>(codepoint)) >= 0)
|
||||
*output++ = character;
|
||||
|
@ -206,11 +206,10 @@ bool VertexBuffer::update(const Vertex* vertices, std::size_t vertexCount, unsig
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool VertexBuffer::update(const VertexBuffer& vertexBuffer)
|
||||
bool VertexBuffer::update([[maybe_unused]] const VertexBuffer& vertexBuffer)
|
||||
{
|
||||
#ifdef SFML_OPENGL_ES
|
||||
|
||||
(void) vertexBuffer;
|
||||
return false;
|
||||
|
||||
#else
|
||||
|
@ -132,7 +132,7 @@ m_config (nullptr)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
EglContext::EglContext(EglContext* shared, const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel) :
|
||||
EglContext::EglContext(EglContext* shared, const ContextSettings& settings, [[maybe_unused]] const WindowImpl& owner, unsigned int bitsPerPixel) :
|
||||
m_display (EGL_NO_DISPLAY),
|
||||
m_context (EGL_NO_CONTEXT),
|
||||
m_surface (EGL_NO_SURFACE),
|
||||
@ -164,8 +164,7 @@ m_config (nullptr)
|
||||
// Create EGL surface (except on Android because the window is created
|
||||
// asynchronously, its activity manager will call it for us)
|
||||
createSurface(owner.getSystemHandle());
|
||||
#else
|
||||
(void) owner;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -55,11 +55,10 @@ using VulkanImplType = sf::priv::VulkanImplWin32;
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Vulkan::isAvailable(bool requireGraphics)
|
||||
bool Vulkan::isAvailable([[maybe_unused]] bool requireGraphics)
|
||||
{
|
||||
#if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE)
|
||||
|
||||
(void) requireGraphics;
|
||||
return false;
|
||||
|
||||
#else
|
||||
@ -71,11 +70,10 @@ bool Vulkan::isAvailable(bool requireGraphics)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
VulkanFunctionPointer Vulkan::getFunction(const char* name)
|
||||
VulkanFunctionPointer Vulkan::getFunction([[maybe_unused]] const char* name)
|
||||
{
|
||||
#if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE)
|
||||
|
||||
(void) name;
|
||||
return nullptr;
|
||||
|
||||
#else
|
||||
|
@ -295,13 +295,10 @@ void WindowImpl::processSensorEvents()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool WindowImpl::createVulkanSurface(const VkInstance& instance, VkSurfaceKHR& surface, const VkAllocationCallbacks* allocator)
|
||||
bool WindowImpl::createVulkanSurface([[maybe_unused]] const VkInstance& instance, [[maybe_unused]] VkSurfaceKHR& surface, [[maybe_unused]] const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
#if defined(SFML_VULKAN_IMPLEMENTATION_NOT_AVAILABLE)
|
||||
|
||||
(void) instance;
|
||||
(void) surface;
|
||||
(void) allocator;
|
||||
return false;
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user