Skip to content

Commit

Permalink
config: fix config.h API definitions
Browse files Browse the repository at this point in the history
This needs to be properly defined as well even after removal of the
pragma before global includes.

Fixes: 82023b9
  • Loading branch information
haasn committed Feb 18, 2023
1 parent 790e3c7 commit c7854aa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
6 changes: 2 additions & 4 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@
#include "pl_alloc.h"
#include "pl_string.h"

#include <libplacebo/config.h>
#undef PL_DEPRECATED
#undef PL_API_BEGIN
#undef PL_API_END
#define PL_DEPRECATED

// Include all of the symbols that should be public in a way that marks them
// as being externally visible. (Otherwise, all symbols are hidden by default)
#define PL_API_BEGIN _Pragma("GCC visibility push(default)")
#define PL_API_END _Pragma("GCC visibility pop")

#include <libplacebo/config.h>

#if PL_API_VER != BUILD_API_VER
#error Header mismatch? <libplacebo/config.h> pulled from elsewhere!
#endif
Expand Down
49 changes: 31 additions & 18 deletions src/include/libplacebo/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,44 @@
// Friendly name (`git describe`) for the overall version of the library
#define PL_VERSION (pl_version())

int pl_fix_ver(void);
const char *pl_version(void);

// Feature tests. These aren't described in further detail, but may be useful
// for programmers wanting to programmatically check for feature support
// in their compiled libplacebo versions.
@extra_defs@

// Extra compiler-specific stuff
#if defined(_MSC_VER)
#define PL_DEPRECATED
#else
#define PL_DEPRECATED __attribute__((deprecated))
#ifndef PL_DEPRECATED
# if defined(_MSC_VER)
# define PL_DEPRECATED
# else
# define PL_DEPRECATED __attribute__((deprecated))
# endif
#endif

#ifndef __has_feature
#define __has_feature(x) 0
#endif

#if (defined(__GNUC__) && (__GNUC__ >= 6)) || __has_feature(enumerator_attributes)
#define PL_DEPRECATED_ENUMERATOR PL_DEPRECATED
#else
#define PL_DEPRECATED_ENUMERATOR
#ifndef PL_DEPRECATED_ENUMERATOR
# if (defined(__GNUC__) && (__GNUC__ >= 6)) || __has_feature(enumerator_attributes)
# define PL_DEPRECATED_ENUMERATOR PL_DEPRECATED
# else
# define PL_DEPRECATED_ENUMERATOR
# endif
#endif

// C++ compatibility
#ifdef __cplusplus
# define PL_API_BEGIN extern "C" {
# define PL_API_END }
#else
# define PL_API_BEGIN
# define PL_API_END
#ifndef PL_API_BEGIN
# ifdef __cplusplus
# define PL_API_BEGIN extern "C" {
# define PL_API_END }
# else
# define PL_API_BEGIN
# define PL_API_END
# endif
#endif

#ifndef __cplusplus
// Disable this warning because libplacebo's params macros override fields
# pragma GCC diagnostic ignored "-Woverride-init"
#endif
Expand All @@ -74,4 +80,11 @@ const char *pl_version(void);
// Deprecated macro for back-compatibility
#define PL_STRUCT(name) struct name##_t

#endif // LIBPLACEBO_CONTEXT_H_
PL_API_BEGIN

int pl_fix_ver(void);
const char *pl_version(void);

PL_API_END

#endif // LIBPLACEBO_CONFIG_H_

0 comments on commit c7854aa

Please sign in to comment.