diff --git a/str_view/str_view.h b/str_view/str_view.h index bca92e6..d7613c2 100644 --- a/str_view/str_view.h +++ b/str_view/str_view.h @@ -37,31 +37,21 @@ # define ATTRIB_NONNULL(...) /**/ # define ATTRIB_NULLTERM(...) /**/ # endif -/* Clang and GCC support static array parameter declarations while - MSVC does not. This is how to solve the differing declaration - signature requirements. */ - -/* A static array parameter declaration helper. Function parameters - may specify an array of a type of at least SIZE elements large, - allowing compiler optimizations and safety errors. Specify - a parameter such as `void func(int size, int arr[STATIC(size)])`. */ -# define STATIC(SIZE) static SIZE -/* A static array parameter declaration helper. Function parameters - may specify an array of a type of at least SIZE elements large, - allowing compiler optimizations and safety errors. Specify - a parameter such as `void func(int size, int arr[STATIC_CONST(size)])`. - This declarations adds the additional constraint that the pointer - to the begginning of the array of types will not move. */ -# define STATIC_CONST(SIZE) static const SIZE -/* A helper macro to enforce only string literals for the SV constructor - macro. GCC and Clang allow this syntax to create more errors when bad - input is provided to the str_view SV constructor.*/ -# define STR_LITERAL(STR) "" STR "" #else # define ATTRIB_PURE /**/ # define ATTRIB_CONST /**/ # define ATTRIB_NONNULL(...) /**/ # define ATTRIB_NULLTERM(...) /**/ +#endif /* __GNUC__ || __clang__ || __INTEL_LLVM_COMPILER */ + +#if defined(_MSVC_VER) || defined(_WIN32) || defined(__CYGWIN__) +# if defined(SV_BUILD_DLL) +# define SV_API __declspec(dllexport) +# elif defined(SV_CONSUME_DLL) +# define SV_API __declspec(dllimport) +# else +# define SV_API /**/ +# endif /* MSVC does not support a static array parameter declaration so the best it can do is promise arrays of at least one element, unlike more dynamic clang and GCC capabilities. */ @@ -77,19 +67,29 @@ /* MSVC does not allow strong enforcement of string literals to the SV str_view constructor. This is a dummy wrapper for compatibility. */ # define STR_LITERAL(STR) STR -#endif /* __GNUC__ || __clang__ || __INTEL_LLVM_COMPILER */ - -#if defined(_MSVC_VER) -# if defined(SV_BUILD_DLL) -# define SV_API __declspec(dllexport) -# elif defined(SV_CONSUME_DLL) -# define SV_API __declspec(dllimport) -# else -# define SV_API /**/ -# endif #else # define SV_API /**/ -#endif /* _MSVC_VER */ +/* Clang and GCC support static array parameter declarations while + MSVC does not. This is how to solve the differing declaration + signature requirements. */ + +/* A static array parameter declaration helper. Function parameters + may specify an array of a type of at least SIZE elements large, + allowing compiler optimizations and safety errors. Specify + a parameter such as `void func(int size, int arr[STATIC(size)])`. */ +# define STATIC(SIZE) static SIZE +/* A static array parameter declaration helper. Function parameters + may specify an array of a type of at least SIZE elements large, + allowing compiler optimizations and safety errors. Specify + a parameter such as `void func(int size, int arr[STATIC_CONST(size)])`. + This declarations adds the additional constraint that the pointer + to the begginning of the array of types will not move. */ +# define STATIC_CONST(SIZE) static const SIZE +/* A helper macro to enforce only string literals for the SV constructor + macro. GCC and Clang allow this syntax to create more errors when bad + input is provided to the str_view SV constructor.*/ +# define STR_LITERAL(STR) "" STR "" +#endif /* _MSVC_VER || _WIN32 || __CYGWIN__ */ #include #include