mirror of
https://github.com/nanopb/nanopb.git
synced 2026-06-06 20:18:31 +00:00
Setting enum data type size is only supported on C23 and C++11 compilers. The previous implementation caused ABI incompatibility when using the option in mixed C/C++ projects. After this commit such cases will be indicated by a compiler error.
23 lines
726 B
Python
23 lines
726 B
Python
# Test that different sizes of enum fields are properly encoded and decoded.
|
|
|
|
Import('env')
|
|
|
|
env.NanopbProto('packed_enum')
|
|
p = env.Program(["packed_enum_unittests.c",
|
|
"packed_enum.pb.c",
|
|
"$COMMON/pb_encode.o",
|
|
"$COMMON/pb_decode.o",
|
|
"$COMMON/pb_common.o"])
|
|
env.RunTest(p)
|
|
|
|
# Enum size specification is supported by C++11 and newer
|
|
env2 = env.Clone()
|
|
env2.Append(CXXFLAGS = "-std=c++11")
|
|
env2.NanopbProtoCpp('enum_intsize')
|
|
p2 = env2.Program(["enum_intsize_unittests.cc",
|
|
"enum_intsize.pb.cpp",
|
|
"$COMMON/pb_encode.o",
|
|
"$COMMON/pb_decode.o",
|
|
"$COMMON/pb_common.o"])
|
|
env2.RunTest(p2)
|