iamandi / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

Compiler Error C2526 with VisualStudio 2010 when including pb_decode.h / pb_encode.h from a C++ File #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The MSVC2010 compiler produces error C2526 when pb_decode.h / pb_encode.h are 
included in a C++ source file (compiling in plain C works, however).

A simple workaround is to put the definitions of _pb_ostream_t / _pb_istream_t
before pb_ostream_from_buffer / pb_istream_from_buffer as in the attached patch.

Error messages:

nanopb/pb_encode.h(51): error C2526: 'pb_ostream_from_buffer' : C linkage 
function cannot return C++ class '_pb_ostream_t'
          nanopb\pb.h(248): see declaration of  '_pb_ostream_t'
nanopb/pb_decode.h(62): error C2526: 'pb_istream_from_buffer' : C linkage 
function cannot return C++ class '_pb_istream_t'
          nanopb\pb.h(247): see declaration of  '_pb_istream_t'

nanopb-Version: 0.2.2

Original issue reported on code.google.com by Markus.S...@googlemail.com on 9 Sep 2013 at 7:49

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 5b9ad17dc201.

Original comment by Petteri.Aimonen on 9 Sep 2013 at 7:56

GoogleCodeExporter commented 9 years ago
Thanks, I merged your patch.

I'll keep this issue open so that I'll remember to add a test case for this. In 
practice, two things:
1) A test case that tests usage of nanopb from a C++ main program.
2) Bothering to setup Jenkins to run the tests automatically on Windows/Visual 
C++ also.

Original comment by Petteri.Aimonen on 9 Sep 2013 at 7:58

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 696a01bf140e.

Original comment by Petteri.Aimonen on 10 Sep 2013 at 2:54

GoogleCodeExporter commented 9 years ago
This bug is now fixed in git master and covered by test cases, tests are run on 
msvc automatically every day.

Original comment by Petteri.Aimonen on 11 Sep 2013 at 1:16

GoogleCodeExporter commented 9 years ago
Fix released in nanopb-0.2.3.

Original comment by Petteri.Aimonen on 18 Sep 2013 at 9:51