summaryrefslogtreecommitdiff
path: root/lib/prefix.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-03-27 20:55:42 +0100
committerDavid Lamparter <equinox@diac24.net>2021-03-27 20:59:39 +0100
commit5d387792337c869724b4a6ff07ee6791a7094b87 (patch)
tree2ca589495aae96b726481ab1e3f3bc8eef3cfbe4 /lib/prefix.h
parent694df37daf95940e923905fdd1096541d860bbfd (diff)
lib: fix transparent_union for clang++
clang does not accept __attribute__((transparent_union)) in C++ source code. We don't need it there anyway so let's just limit it to C. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/prefix.h')
-rw-r--r--lib/prefix.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index b2f3b0592f..6f1c219ba8 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -315,10 +315,12 @@ struct prefix_sg {
#ifndef __cplusplus
#define prefixtype(uname, typename, fieldname) \
typename *fieldname;
+#define TRANSPARENT_UNION __attribute__((transparent_union))
#else
#define prefixtype(uname, typename, fieldname) \
typename *fieldname; \
uname(typename *x) { this->fieldname = x; }
+#define TRANSPARENT_UNION
#endif
union prefixptr {
@@ -328,7 +330,7 @@ union prefixptr {
prefixtype(prefixptr, struct prefix_evpn, evp)
prefixtype(prefixptr, struct prefix_fs, fs)
prefixtype(prefixptr, struct prefix_rd, rd)
-} __attribute__((transparent_union));
+} TRANSPARENT_UNION;
union prefixconstptr {
prefixtype(prefixconstptr, const struct prefix, p)
@@ -337,7 +339,10 @@ union prefixconstptr {
prefixtype(prefixconstptr, const struct prefix_evpn, evp)
prefixtype(prefixconstptr, const struct prefix_fs, fs)
prefixtype(prefixconstptr, const struct prefix_rd, rd)
-} __attribute__((transparent_union));
+} TRANSPARENT_UNION;
+
+#undef prefixtype
+#undef TRANSPARENT_UNION
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16