From: Simon McVittie Date: Mon, 10 Aug 2020 10:26:48 +0100 Subject: Avoid multiple definitions of some global variables gcc 10 defaults to -fno-common, which means that the same global variable being defined by multiple translation units (roughly, C source files) causes a linking error. This is similar to the behaviour of global functions, and C++'s "one-definition rule". The way to get a global variable shared between translation units is to declare it as extern (usually in a header file), and then ensure that exactly one translation unit contains a definition. Signed-off-by: Simon McVittie Bug-Debian: https://bugs.debian.org/957237 Forwarded: no --- qcc.h | 2 ++ qcc_pr_comp.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qcc.h b/qcc.h index 41736bc..9579613 100644 --- a/qcc.h +++ b/qcc.h @@ -279,6 +279,8 @@ There are no ++ / -- operators, or operate/assign operators. #include "hash.h" extern hashtable_t compconstantstable; extern hashtable_t globalstable, localstable; +extern hashtable_t floatconstdefstable; +extern hashtable_t stringconstdefstable; #endif #ifdef WRITEASM diff --git a/qcc_pr_comp.c b/qcc_pr_comp.c index c0f91cb..40020f6 100644 --- a/qcc_pr_comp.c +++ b/qcc_pr_comp.c @@ -3731,7 +3731,6 @@ QCC_def_t *QCC_MakeVectorDef(float a, float b, float c) return cn; } -hashtable_t floatconstdefstable; QCC_def_t *QCC_MakeFloatDef(float value) { QCC_def_t *cn; @@ -3773,7 +3772,6 @@ QCC_def_t *QCC_MakeFloatDef(float value) return cn; } -hashtable_t stringconstdefstable; QCC_def_t *QCC_MakeStringDef(char *value) { QCC_def_t *cn;