Build fixes for Windows/Visual C++

This commit is contained in:
Petteri Aimonen
2013-09-10 17:44:32 +03:00
parent e681dd0d75
commit f04ab838ab
13 changed files with 141 additions and 49 deletions

View File

@@ -4,9 +4,9 @@
Import("env")
env.NanopbProto("alltypes")
env.Program(["encode_alltypes.c", "alltypes.pb.c", "#common/pb_encode.o"])
env.Program(["decode_alltypes.c", "alltypes.pb.c", "#common/pb_decode.o"])
enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "#common/pb_encode.o"])
dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "#common/pb_decode.o"])
env.RunTest("encode_alltypes")
env.RunTest(["decode_alltypes", "encode_alltypes.output"])
env.RunTest(enc)
env.RunTest([dec, "encode_alltypes.output"])

View File

@@ -113,18 +113,20 @@ int main(int argc, char **argv)
alltypes.end = 1099;
uint8_t buffer[1024];
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
/* Now encode it and check if we succeeded. */
if (pb_encode(&stream, AllTypes_fields, &alltypes))
{
fwrite(buffer, 1, stream.bytes_written, stdout);
return 0; /* Success */
}
else
{
fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream));
return 1; /* Failure */
uint8_t buffer[1024];
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
/* Now encode it and check if we succeeded. */
if (pb_encode(&stream, AllTypes_fields, &alltypes))
{
fwrite(buffer, 1, stream.bytes_written, stdout);
return 0; /* Success */
}
else
{
fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&stream));
return 1; /* Failure */
}
}
}