Skip to content

Commit

Permalink
detect windows more directly by os
Browse files Browse the repository at this point in the history
  • Loading branch information
agl-alexglopez committed Aug 5, 2024
1 parent 1bb469d commit a899ae4
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions str_view/str_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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 <stdbool.h>
#include <stddef.h>
Expand Down

0 comments on commit a899ae4

Please sign in to comment.