From 2c903943d95b6af00a4819ac03ec5f010ba91076 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 7 Aug 2015 22:30:10 -0700 Subject: C++ static forward issue. * lib.h (static_forward, static_def): New macros for dealing with C++ static forward declaration problem. * syslog.c (syslog_strm_ops): Use static forward macros. --- ChangeLog | 10 ++++++++++ lib.h | 8 ++++++++ syslog.c | 6 +++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 216038b4..7ddfd2e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-08-07 Kaz Kylheku + + C++ static forward issue. + + * lib.h (static_forward, static_def): New macros + for dealing with C++ static forward declaration problem. + + * syslog.c (syslog_strm_ops): Use static + forward macros. + 2015-08-07 Kaz Kylheku C++ upkeep: resolve multiple definitions of fun_k. diff --git a/lib.h b/lib.h index fd05954f..85f0b6e2 100644 --- a/lib.h +++ b/lib.h @@ -954,3 +954,11 @@ loc list_collect_append(loc pptail, val obj); #define negone num_fast(-1) #define maxint num_fast(NUM_MAX) #define minint num_fast(NUM_MIN) + +#ifdef __cplusplus +#define static_forward(decl) namespace { extern decl; } +#define static_def(def) namespace { def; } +#else +#define static_forward(decl) static decl; +#define static_def(def) static def; +#endif diff --git a/syslog.c b/syslog.c index 0cb1d80e..248c3b5b 100644 --- a/syslog.c +++ b/syslog.c @@ -51,7 +51,7 @@ struct syslog_strm { val prio_k; -static struct strm_ops syslog_strm_ops; +static_forward(struct strm_ops syslog_strm_ops) void syslog_init(void) { @@ -212,7 +212,7 @@ static val syslog_set_prop(val stream, val ind, val prop) return nil; } -static struct strm_ops syslog_strm_ops = +static_def(struct strm_ops syslog_strm_ops = strm_ops_init(cobj_ops_init(eq, stream_print_op, cobj_destroy_stub_op, @@ -225,7 +225,7 @@ static struct strm_ops syslog_strm_ops = 0, 0, 0, 0, 0, 0, 0, 0, syslog_get_prop, syslog_set_prop, - 0, 0, 0); + 0, 0, 0)) val make_syslog_stream(val prio) { -- cgit v1.2.3