···66import json
77import re
8899+def write_cpp_header_guard_start(f):
1010+ """Write the starting C in C++ header guard"""
1111+ f.write('''
1212+#ifdef __cplusplus
1313+extern "C" {
1414+#endif
1515+''')
1616+1717+def write_cpp_header_guard_end(f):
1818+ """Write the ending C in C++ header guard"""
1919+ f.write('''
2020+#ifdef __cplusplus
2121+}
2222+#endif
2323+''')
9241025def write_with_wrapped_args(f, start, args, indent):
1126 """Write something like a declaration or call."""
+13-3
src/xrt/ipc/shared/proto.py
···66import argparse
7788from ipcproto.common import (Proto, write_decl, write_invocation,
99- write_result_handler)
99+ write_result_handler, write_cpp_header_guard_start,
1010+ write_cpp_header_guard_end)
10111112header = '''// Copyright 2020, Collabora, Ltd.
1213// SPDX-License-Identifier: BSL-1.0
···221222#include "ipc_protocol_generated.h"
222223#include "client/ipc_client.h"
223224224224-225225-226225''')
226226+ write_cpp_header_guard_start(f)
227227+ f.write("\n")
227228228229 for call in p.calls:
229230 call.write_call_decl(f)
230231 f.write(";\n")
232232+233233+ write_cpp_header_guard_end(f)
234234+231235 f.close()
232236233237···383387384388385389''')
390390+391391+ write_cpp_header_guard_start(f)
392392+ f.write("\n")
393393+386394 # This decl is constant, but we must write it here
387395 # because it depends on a generated enum.
388396 write_decl(
···399407 for call in p.calls:
400408 call.write_handler_decl(f)
401409 f.write(";\n")
410410+411411+ write_cpp_header_guard_end(f)
402412 f.close()
403413404414