Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Warnings in C++ header files generated by gen-cppcode.py


Copy link to this message
-
Warnings in C++ header files generated by gen-cppcode.py
Hi -

The Avro C++ documentation
(http://avro.apache.org/docs/current/api/cpp/html/index.html) shows an
example of a C++ object generated using the python script
gen-cppcode.py, to represent the data for an example schema. I followed
the example to generate the example.hh file as described in the
documentation.

When I compile this code using g++ ( g++ (GCC) 4.1.2 20080704 (Red Hat
4.1.2-48) ), I get the following warnings:

example.hh: In constructor
'Math::complex_Layout::complex_Layout(size_t)':
example.hh:68: warning: invalid access to non-static data member
'Math::complex::real' of NULL object
example.hh:68: warning: (perhaps the 'offsetof' macro was used
incorrectly)
example.hh:69: warning: invalid access to non-static data member
'Math::complex::imaginary' of NULL object
example.hh:69: warning: (perhaps the 'offsetof' macro was used
incorrectly)

The issue appears to be that the generated "struct complex", is not a
Plain Old Data (POD) structureand the offsetof() macro is only supposed
to be used with POD structures. This limitation of offsetof() is
described in the following article:
http://thewayofc.blogspot.com/2008/05/what-is-really-pod-class.html

Here are the questions I had:

1. Has anyone run across this limitation in gen-cppcode.py? How did you
get around it?

2. Does anyone use the gen-cppcode.py in production code? If not, what
do you use instead?

Thanks,
Vivek Nadkarni