Make symbols hidden by default.

Adds "-fvisibility=hidden" to CFLAGS and LDFLAGS. Defines macro
KVZ_PUBLIC for marking symbols that should be visible.
This commit is contained in:
Arttu Ylä-Outinen 2015-07-13 14:20:21 +03:00
parent 9cfbd55ea8
commit a4ec92081a
3 changed files with 19 additions and 4 deletions

View file

@ -34,9 +34,10 @@ WARNINGS = -Wall -Wtype-limits -Wvla
INCLUDEDIRS = -I. -I./strategies -I./extras -I..
ASFLAGS += $(INCLUDEDIRS)
CFLAGS += -O2 -g -Werror -ftree-vectorize -fpic -std=gnu99
CFLAGS += -O2 -g -Werror -ftree-vectorize -fpic -fvisibility=hidden -std=gnu99
CFLAGS += -DKVZ_DLL_EXPORTS
CFLAGS += $(INCLUDEDIRS) $(WARNINGS)
LDFLAGS += -lm -pthread
LDFLAGS += -fvisibility=hidden -lm -pthread
ifeq (, $(ARCH))
ARCH = $(shell uname -m)

View file

@ -168,7 +168,8 @@ static int kvazaar_encode(kvz_encoder *enc,
return 1;
}
kvz_api kvz_8bit_api = {
static const kvz_api kvz_8bit_api = {
.config_alloc = config_alloc,
.config_init = config_init,
.config_destroy = config_destroy,

View file

@ -34,6 +34,18 @@
extern "C" {
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
#ifdef KVZ_DLL_EXPORTS
#define KVZ_PUBLIC __declspec(dllexport)
#else
#define KVZ_PUBLIC __declspec(dllimport)
#endif
#elif defined(__GNUC__)
#define KVZ_PUBLIC __attribute__ ((visibility ("default")))
#else
#define KVZ_PUBLIC
#endif
/**
* Maximum length of a GoP structure.
*/
@ -224,7 +236,8 @@ typedef struct kvz_api {
#define KVZ_API_CONCAT(func, version) func ## _apiv ## version
#define KVZ_API_EXPAND_VERSION(func, version) KVZ_API_CONCAT(func, version)
#define kvz_api_get KVZ_API_EXPAND_VERSION(kvz_api_get, KVZ_API_VERSION)
const kvz_api* kvz_api_get(int bit_depth);
KVZ_PUBLIC const kvz_api * kvz_api_get(int bit_depth);
#ifdef __cplusplus
}