switchbrew / libnx

Library for Switch Homebrew

Home Page:https://switchbrew.github.io/libnx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AUDREN_CONSTEXPR breaks pre-C++14 builds

dwarfcrank opened this issue · comments

AUDREN_CONSTEXPR in switch/services/audren.h is defined as constexpr for C++ code. However, audrenGetInputParamSize and audrenGetOutputParamSize are more complex constexpr functions which are only supported since C++14. The switch-examples template Makefile uses -std=gnu++11 for C++ code, breaking the build:

/opt/devkitpro/libnx/include/switch/services/audren.h: In function 'constexpr size_t audrenGetInputParamSize(const AudioRendererConfig*)':
/opt/devkitpro/libnx/include/switch/services/audren.h:305:1: error: body of 'constexpr' function 'constexpr size_t audrenGetInputParamSize(const AudioRendererConfig*)' not a return-statement
 }
 ^
/opt/devkitpro/libnx/include/switch/services/audren.h: In function 'constexpr size_t audrenGetOutputParamSize(const AudioRendererConfig*)':
/opt/devkitpro/libnx/include/switch/services/audren.h:318:1: error: body of 'constexpr' function 'constexpr size_t audrenGetOutputParamSize(const AudioRendererConfig*)' not a return-statement
 }

AUDREN_CONSTEXPR should be guarded by the appropriate feature test macros, e.g.:

#if defined(__cplusplus) && (__cpp_constexpr >= 201304)
#define AUDREN_CONSTEXPR constexpr
#else
#define AUDREN_CONSTEXPR static inline
#endif

Also, should the template Makefiles be updated to use C++17 by default?

i have the same error...

commented

The default C++ standard in GCC (when you don't specify any standard explicitly) is now C++14. I agree that the template makefiles should be updated to remove C++11 in favor of the default C++14.

Fixed