mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
utility: Move helper macros
As not everything in the plugin needs to use these, they have no place in the plugin header, and thus are now in utility.hpp
This commit is contained in:
parent
1bcca6cb33
commit
3f92e1cc89
3 changed files with 40 additions and 40 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include "strings.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
// OBS
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -43,46 +43,6 @@
|
|||
#define P_LOG_INFO(...) P_LOG(LOG_INFO, __VA_ARGS__)
|
||||
#define P_LOG_DEBUG(...) P_LOG(LOG_DEBUG, __VA_ARGS__)
|
||||
|
||||
// Utility
|
||||
#define vstr(s) dstr(s)
|
||||
#define dstr(s) #s
|
||||
|
||||
#ifndef __FUNCTION_NAME__
|
||||
#if defined(_WIN32) || defined(_WIN64) //WINDOWS
|
||||
#define __FUNCTION_NAME__ __FUNCTION__
|
||||
#else //*NIX
|
||||
#define __FUNCTION_NAME__ __func__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define INITIALIZER(f) \
|
||||
static void f(void); \
|
||||
struct f##_t_ { \
|
||||
f##_t_(void) \
|
||||
{ \
|
||||
f(); \
|
||||
} \
|
||||
}; \
|
||||
static f##_t_ f##_; \
|
||||
static void f(void)
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma section(".CRT$XCU", read)
|
||||
#define INITIALIZER2_(f, p) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker, "/include:" p #f "_")) static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define INITIALIZER(f) INITIALIZER2_(f, "")
|
||||
#else
|
||||
#define INITIALIZER(f) INITIALIZER2_(f, "_")
|
||||
#endif
|
||||
#else
|
||||
#define INITIALIZER(f) \
|
||||
static void f(void) __attribute__((constructor)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
// Initializer & Finalizer
|
||||
extern std::list<std::function<void()>> initializerFunctions;
|
||||
extern std::list<std::function<void()>> finalizerFunctions;
|
||||
|
|
|
@ -44,3 +44,42 @@ typename std::enable_if<enable_bitmask_operators<Enum>::enable, Enum>::type oper
|
|||
struct enable_bitmask_operators<x> { \
|
||||
static const bool enable = true; \
|
||||
};
|
||||
|
||||
#define vstr(s) dstr(s)
|
||||
#define dstr(s) #s
|
||||
|
||||
#ifndef __FUNCTION_NAME__
|
||||
#if defined(_WIN32) || defined(_WIN64) //WINDOWS
|
||||
#define __FUNCTION_NAME__ __FUNCTION__
|
||||
#else //*NIX
|
||||
#define __FUNCTION_NAME__ __func__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define INITIALIZER(f) \
|
||||
static void f(void); \
|
||||
struct f##_t_ { \
|
||||
f##_t_(void) \
|
||||
{ \
|
||||
f(); \
|
||||
} \
|
||||
}; \
|
||||
static f##_t_ f##_; \
|
||||
static void f(void)
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma section(".CRT$XCU", read)
|
||||
#define INITIALIZER2_(f, p) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker, "/include:" p #f "_")) static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define INITIALIZER(f) INITIALIZER2_(f, "")
|
||||
#else
|
||||
#define INITIALIZER(f) INITIALIZER2_(f, "_")
|
||||
#endif
|
||||
#else
|
||||
#define INITIALIZER(f) \
|
||||
static void f(void) __attribute__((constructor)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue