Skip to content

Commit

Permalink
C lib: Hide non-API functions from shared library
Browse files Browse the repository at this point in the history
  • Loading branch information
terryburton committed Jun 16, 2024
1 parent be859a2 commit a0ae54a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/c-lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ endif
CC = emcc
CFLAGS_G =
CFLAGS_O = -O3
CFLAGS_V =
BUILD_DIR = build-wasm
LDFLAGS_WASM = -s WASM=$(DO_WASM) -s MODULARIZE=1 -s EXPORT_NAME=createGS1encoderModule -s EXPORT_ES6=1 -s EXPORTED_RUNTIME_METHODS='["cwrap","getValue","UTF8ToString"]' -s EXPORTED_FUNCTIONS='["_malloc","_free"]' -s ALLOW_MEMORY_GROWTH=1
SYN_DICT = gs1-syntax-dictionary.txt
else
CFLAGS_G = -g
CFLAGS_O = -O2
CFLAGS_V = -fvisibility=hidden
endif

ifeq ($(MAKECMDGOALS),clean-test)
Expand Down Expand Up @@ -145,7 +147,7 @@ CFLAGS_FORTIFY = -D_FORTIFY_SOURCE=2
NPROC = nproc
endif

CFLAGS = $(CFLAGS_G) $(CFLAGS_O) $(CFLAGS_FORTIFY) -Wall -Wextra -Wconversion -Wformat -Wformat-security -Wdeclaration-after-statement -pedantic -Werror -MMD -fPIC -DGS1_LINTER_ERR_STR_EN $(SAN_CFLAGS) $(UNIT_TEST_CFLAGS) $(DEBUG_CFLAGS) $(SLOW_TESTS_CFLAGS)
CFLAGS = $(CFLAGS_G) $(CFLAGS_O) $(CFLAGS_FORTIFY) $(CFLAGS_V) -Wall -Wextra -Wconversion -Wformat -Wformat-security -Wdeclaration-after-statement -pedantic -Werror -MMD -fPIC -DGS1_LINTER_ERR_STR_EN $(SAN_CFLAGS) $(UNIT_TEST_CFLAGS) $(DEBUG_CFLAGS) $(SLOW_TESTS_CFLAGS)

APP = $(BUILD_DIR)/$(NAME).$(BIN_SUFFIX)
APP_STATIC = $(BUILD_DIR)/$(NAME)-static.$(BIN_SUFFIX)
Expand Down
2 changes: 2 additions & 0 deletions src/c-lib/gs1encoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@
# define GS1_ENCODERS_API EMSCRIPTEN_KEEPALIVE
#elif _WIN32
# define GS1_ENCODERS_API __declspec(dllexport)
#elif __GNUC__ >= 4
# define GS1_ENCODERS_API __attribute__((visibility ("default")))
#else
# define GS1_ENCODERS_API
#endif
Expand Down
9 changes: 8 additions & 1 deletion src/c-lib/syntax/gs1syntaxdictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,14 @@ typedef enum


#ifdef GS1_LINTER_ERR_STR_EN
extern const char *gs1_lint_err_str[];
#ifdef __EMSCRIPTEN__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wignored-attributes"
#endif
GS1_SYNTAX_DICTIONARY_API extern const char *gs1_lint_err_str[];
#ifdef __EMSCRIPTEN__
#pragma clang diagnostic pop
#endif
#endif


Expand Down
2 changes: 1 addition & 1 deletion src/java/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ limitations under the License.

<target name="cc">
<exec executable="cc" failonerror="true">
<arg line="-fPIC -O2 -g -Werror" />
<arg line="-fPIC -O2 -g -Werror -fvisibility=hidden" />
<arg line="-I${clib}" />
<arg line="-I${java.home}/../include" />
<arg line="-I${java.home}/../include/${os.family}" />
Expand Down

0 comments on commit a0ae54a

Please sign in to comment.