Skip to content

Commit aa9e87f

Browse files
committed
persist-tool: fix multiple definition of globals
Headers should not define variables. Including them into different compilation units results in multiple definitions of the same name. Detected with the -fno-common gcc flag. Signed-off-by: László Várady <laszlo.varady@protonmail.com>
1 parent 4226fa1 commit aa9e87f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

persist-tool/add.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include "cfg.h"
3333
#include "persist-tool.h"
3434

35-
gchar *persist_state_dir;
36-
gchar *persist_state_name;
35+
extern gchar *persist_state_dir;
36+
extern gchar *persist_state_name;
3737

3838
gint add_main(int argc, char *argv[]);
3939

persist-tool/generate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include "persist-state.h"
3333
#include "cfg.h"
3434

35-
gboolean force_generate;
36-
gchar *generate_output_dir;
35+
extern gboolean force_generate;
36+
extern gchar *generate_output_dir;
3737

3838
gint generate_main(int argc, char *argv[]);
3939

persist-tool/persist-tool.c

+6
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,17 @@ void persist_tool_free(PersistTool *self)
135135
g_free(self);
136136
}
137137

138+
gchar *persist_state_dir;
139+
gchar *persist_state_name;
140+
gboolean force_generate;
141+
gchar *generate_output_dir;
142+
138143
static GOptionEntry dump_options[] =
139144
{
140145
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL }
141146
};
142147

148+
143149
static GOptionEntry add_options[] =
144150
{
145151
{ "output-dir", 'o', 0, G_OPTION_ARG_STRING, &persist_state_dir, "The directory where persist file is located.", "<directory>" },

0 commit comments

Comments
 (0)