'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
+nanopb_version = "nanopb-0.1.7-dev"
try:
import google.protobuf.descriptor_pb2 as descriptor
# Generation of single fields
# ---------------------------------------------------------------------------
-
+import time
import os.path
# Values are tuple (c type, pb ltype)
'''
yield '/* Automatically generated nanopb header */\n'
+ yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
symbol = headername.replace('.', '_').upper()
yield '#ifndef _PB_%s_\n' % symbol
for dependency in dependencies:
noext = os.path.splitext(dependency)[0]
yield '#include "%s.pb.h"\n' % noext
- yield '\n'
+
+ yield '#ifdef __cplusplus\n'
+ yield 'extern "C" {\n'
+ yield '#endif\n\n'
yield '/* Enum definitions */\n'
for enum in enums:
yield 'STATIC_ASSERT((%s), YOU_MUST_DEFINE_PB_FIELD_32BIT)\n' % assertion
yield '#endif\n'
+ yield '\n#ifdef __cplusplus\n'
+ yield '} /* extern "C" */\n'
+ yield '#endif\n'
+
# End of header
yield '\n#endif\n'
'''Generate content for a source file.'''
yield '/* Automatically generated nanopb constant definitions */\n'
+ yield '/* Generated by %s at %s. */\n\n' % (nanopb_version, time.asctime())
yield '#include "%s"\n\n' % headername
for msg in messages: