From: Christophe CURIS <[email protected]>
Some header were creating variable, this is a bad practice which
is likely to not behave as expected. This creates one distinct
variable in each object file that used the header, and:
- on well behaved compiler, this ends up in a link error (see
commit 39fdb451ba6ff84430507e327fa01a43f40b7315 for an example)
- on bad behaving compiler, this can be linked as multiple local
variable, thus having strange effects when running program
- on insouciant compiler (who said gcc?) the variables are
silently merged, hiding portability issues
---
src/screen.c | 5 +++++
src/screen.h | 4 ++--
util/wmmenugen.c | 4 ++++
util/wmmenugen.h | 4 ++--
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/screen.c b/src/screen.c
index 37e4da3..c61aa1f 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -81,6 +81,11 @@ extern int wScreenCount;
extern int wXkbSupported;
#endif
+#ifdef HAVE_XRANDR
+Bool has_randr;
+int randr_event_base;
+#endif
+
extern WDDomain *WDWindowMaker;
/**** Local ****/
diff --git a/src/screen.h b/src/screen.h
index 861983f..be27cdb 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -36,8 +36,8 @@
#define WTB_MENU 6
#ifdef HAVE_XRANDR
-Bool has_randr;
-int randr_event_base;
+extern Bool has_randr;
+extern int randr_event_base;
#endif
typedef struct {
diff --git a/util/wmmenugen.c b/util/wmmenugen.c
index 82ad8ce..ac3846b 100644
--- a/util/wmmenugen.c
+++ b/util/wmmenugen.c
@@ -45,6 +45,10 @@ char *terminal;
extern char *__progname;
+/* Global Variables from wmmenugen.h */
+WMTreeNode *menu;
+char *env_lang, *env_ctry, *env_enc, *env_mod;
+
int main(int argc, char **argv)
{
struct stat st;
diff --git a/util/wmmenugen.h b/util/wmmenugen.h
index cdefbe9..3a60ab2 100644
--- a/util/wmmenugen.h
+++ b/util/wmmenugen.h
@@ -46,9 +46,9 @@ typedef struct {
/* the abstract menu tree
*/
-WMTreeNode *menu;
+extern WMTreeNode *menu;
-char *env_lang, *env_ctry, *env_enc, *env_mod;
+extern char *env_lang, *env_ctry, *env_enc, *env_mod;
/* wmmenu_misc.c
*/
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].