Skip to content

Commit 657d3d9

Browse files
committed
libxo/*.h fix libxo header include when the source is C++
C++ needs extern C to disable C++ name mangling. To use libxo in C++ it is better to include extern "C" guardian
1 parent fd5db1b commit 657d3d9

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

libxo/xo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#ifndef INCLUDE_XO_H
2121
#define INCLUDE_XO_H
2222

23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif /* __cplusplus */
26+
2327
#include <stdio.h>
2428
#include <sys/types.h>
2529
#include <stdarg.h>
@@ -736,4 +740,8 @@ xo_map_add_file (xo_handle_t *xop, const char *fname);
736740
int
737741
xo_filter_add (xo_handle_t *xop, const char *vp);
738742

743+
#ifdef __cplusplus
744+
}
745+
#endif /* __cplusplus */
746+
739747
#endif /* INCLUDE_XO_H */

libxo/xo_buf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#ifndef XO_BUF_H
2020
#define XO_BUF_H
2121

22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif /* __cplusplus */
25+
2226
#include "xo_private.h"
2327

2428
#define XO_BUFSIZ (8*1024) /* Normal buffer size */
@@ -280,4 +284,8 @@ xo_buf_force_nul (xo_buffer_t *dst)
280284
dst->xb_curp -= 1;
281285
}
282286

287+
#ifdef __cplusplus
288+
}
289+
#endif /* __cplusplus */
290+
283291
#endif /* XO_BUF_H */

libxo/xo_encoder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#ifndef XO_ENCODER_H
1919
#define XO_ENCODER_H
2020

21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif /* __cplusplus */
24+
2125
#include <string.h>
2226

2327
#include "xo_private.h"
@@ -208,4 +212,8 @@ xo_whiteboard_op_name (xo_whiteboard_op_t op);
208212
void
209213
xo_failure (xo_handle_t *xop, const char *fmt, ...);
210214

215+
#ifdef __cplusplus
216+
}
217+
#endif /* __cplusplus */
218+
211219
#endif /* XO_ENCODER_H */

libxo/xo_explicit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#ifndef XO_EXPLICIT_H
1313
#define XO_EXPLICIT_H
1414

15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif /* __cplusplus */
18+
1519
/*
1620
* NOTE WELL: This file is needed to software that implements an
1721
* explicit transition between libxo states on its internal stack.
@@ -58,4 +62,8 @@ void
5862
xo_explicit_transition (xo_handle_t *xop, xo_state_t new_state,
5963
const char *tag, xo_xof_flags_t flags);
6064

65+
#ifdef __cplusplus
66+
}
67+
#endif /* __cplusplus */
68+
6169
#endif /* XO_EXPLICIT_H */

0 commit comments

Comments
 (0)