ruby/prism/defines.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 строки
2.3 KiB
C
Исходник Обычный вид История

/**
* @file defines.h
*
* Macro definitions used throughout the prism library.
*
* This file should be included first by any *.h or *.c in prism for consistency
* and to ensure that the macros are defined before they are used.
*/
2023-09-27 19:24:48 +03:00
#ifndef PRISM_DEFINES_H
#define PRISM_DEFINES_H
2023-06-30 21:30:24 +03:00
#include <ctype.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
2023-06-30 21:30:24 +03:00
#include <stdio.h>
#include <string.h>
/**
* By default, we compile with -fvisibility=hidden. When this is enabled, we
* need to mark certain functions as being publically-visible. This macro does
* that in a compiler-agnostic way.
*/
2023-09-27 19:24:48 +03:00
#ifndef PRISM_EXPORTED_FUNCTION
# ifdef PRISM_EXPORT_SYMBOLS
# ifdef _WIN32
2023-09-27 19:24:48 +03:00
# define PRISM_EXPORTED_FUNCTION __declspec(dllexport) extern
# else
2023-09-27 19:24:48 +03:00
# define PRISM_EXPORTED_FUNCTION __attribute__((__visibility__("default"))) extern
# endif
# else
2023-09-27 19:24:48 +03:00
# define PRISM_EXPORTED_FUNCTION
# endif
#endif
/**
* Certain compilers support specifying that a function accepts variadic
* parameters that look like printf format strings to provide a better developer
* experience when someone is using the function. This macro does that in a
* compiler-agnostic way.
*/
#if defined(__GNUC__)
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(printf, string_index, argument_index)))
#elif defined(__clang__)
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((__format__(__printf__, string_index, argument_index)))
#else
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index)
#endif
/**
* GCC will warn if you specify a function or parameter that is unused at
* runtime. This macro allows you to mark a function or parameter as unused in a
* compiler-agnostic way.
*/
#if defined(__GNUC__)
2023-09-27 19:24:48 +03:00
# define PRISM_ATTRIBUTE_UNUSED __attribute__((unused))
#else
2023-09-27 19:24:48 +03:00
# define PRISM_ATTRIBUTE_UNUSED
#endif
/**
* Old Visual Studio versions do not support the inline keyword, so we need to
* define it to be __inline.
*/
#if defined(_MSC_VER) && !defined(inline)
# define inline __inline
#endif
/**
* Old Visual Studio versions before 2015 do not implement sprintf, but instead
* implement _snprintf. We standard that here.
*/
#if !defined(snprintf) && defined(_MSC_VER) && (_MSC_VER < 1900)
# define snprintf _snprintf
#endif
#endif