Hello,
I have a struct like
typedef struct __attribute__ ((__packed__))
{
uint8_t x;
int16_t y;
uint32_t z;
double p;
} MyDataType;
This doesn't work with typegen, unless the __attribute__ ((__packed__))
is removed. The error is
--------
[ 15%] Building CXX object
CMakeFiles/foo-typekit-gnulinux.dir/type_info/MyDataType___std__string.cpp.o
In file included from
/home/sagar/excludes/orocos-playground/src/datatypes/src/types/type_info/MyDataType___std__string.cpp:4:0:
/home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:
In instantiation of ‘void boost::serialization::serialize(Archive&,
MyDataType&, unsigned int) [with Archive = RTT::types::type_discovery]’:
/usr/include/boost/serialization/serialization.hpp:128:9: required
from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned
int) [with Archive = RTT::types::type_discovery; T = MyDataType]’
/usr/include/boost/archive/detail/iserializer.hpp:373:13: required
from ‘static void
boost::archive::detail::load_non_pointer_type<Archive>::load_only::invoke(Archive&,
const T&) [with T = MyDataType; Archive = RTT::types::type_discovery]’
/home/sagar/excludes/orocos-toolchain/install/include/rtt/types/type_discovery.hpp:164:17:
required from ‘void RTT::types::type_discovery::discover(T&) [with T
= MyDataType]’
/home/sagar/excludes/orocos-toolchain/install/include/rtt/types/StructTypeInfo.hpp:87:17:
required from ‘std::vector<std::basic_string
T = MyDataType; bool has_ostream = false]’
/home/sagar/excludes/orocos-playground/src/datatypes/src/types/type_info/MyDataType___std__string.cpp:90:67:
required from here
/home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:30:1:
error: cannot bind packed field ‘b.MyDataType::y’ to ‘short int&’
/home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:31:1:
error: cannot bind packed field ‘b.MyDataType::z’ to ‘unsigned int&’
/home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:32:1:
error: cannot bind packed field ‘b.MyDataType::p’ to ‘double&’
make[2]: ***
[CMakeFiles/foo-typekit-gnulinux.dir/type_info/MyDataType___std__string.cpp.o]
Error 1
make[1]: *** [CMakeFiles/foo-typekit-gnulinux.dir/all] Error 2
make: *** [all] Error 2
---------
Is there a way to get typegen working with __attribute__ ((__packed__)) ?
Thanks in advance,
Sagar
typegen + __attribute__ ((__packed__))
On Mon, Oct 8, 2012 at 9:37 PM, Sagar Behere <sagar [dot] behere [..] ...> wrote:
> RTT::types::StructTypeInfo<T, has_ostream>::getMemberNames() const [with
> Hello,
>
> I have a struct like
>
> typedef struct __attribute__ ((__packed__))
> {
> uint8_t x;
> int16_t y;
> uint32_t z;
> double p;
> } MyDataType;
>
> This doesn't work with typegen, unless the __attribute__ ((__packed__))
> is removed. The error is
>
> --------
> [ 15%] Building CXX object
> CMakeFiles/foo-typekit-gnulinux.dir/type_info/MyDataType___std__string.cpp.o
> In file included from
> /home/sagar/excludes/orocos-playground/src/datatypes/src/types/type_info/MyDataType___std__string.cpp:4:0:
> /home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:
> In instantiation of ‘void boost::serialization::serialize(Archive&,
> MyDataType&, unsigned int) [with Archive = RTT::types::type_discovery]’:
> /usr/include/boost/serialization/serialization.hpp:128:9: required
> from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned
> int) [with Archive = RTT::types::type_discovery; T = MyDataType]’
> /usr/include/boost/archive/detail/iserializer.hpp:373:13: required
> from ‘static void
> boost::archive::detail::load_non_pointer_type<Archive>::load_only::invoke(Archive&,
> const T&) [with T = MyDataType; Archive = RTT::types::type_discovery]’
> /home/sagar/excludes/orocos-toolchain/install/include/rtt/types/type_discovery.hpp:164:17:
> required from ‘void RTT::types::type_discovery::discover(T&) [with T
> = MyDataType]’
> /home/sagar/excludes/orocos-toolchain/install/include/rtt/types/StructTypeInfo.hpp:87:17:
> required from ‘std::vector<std::basic_string
> T = MyDataType; bool has_ostream = false]’
> /home/sagar/excludes/orocos-playground/src/datatypes/src/types/type_info/MyDataType___std__string.cpp:90:67:
> required from here
> /home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:30:1:
> error: cannot bind packed field ‘b.MyDataType::y’ to ‘short int&’
> /home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:31:1:
> error: cannot bind packed field ‘b.MyDataType::z’ to ‘unsigned int&’
> /home/sagar/excludes/orocos-playground/src/datatypes/src/types/types/foo/type_info/BoostSerialization.hpp:32:1:
> error: cannot bind packed field ‘b.MyDataType::p’ to ‘double&’
> make[2]: ***
> [CMakeFiles/foo-typekit-gnulinux.dir/type_info/MyDataType___std__string.cpp.o]
> Error 1
> make[1]: *** [CMakeFiles/foo-typekit-gnulinux.dir/all] Error 2
> make: *** [all] Error 2
> ---------
>
> Is there a way to get typegen working with __attribute__ ((__packed__)) ?
Sylvain is right, it's not typegen. We generate some boost functions
that take a reference to the
fields of your struct. Since taking a reference to a packed member
variable might fail at runtime
on some systems, the compiler bails out.
I've seen reports of other compiler versions accepting it though...
which is weird.
I've seen workarounds that use pointers instead of references, which
would mean that we have to
make a major api change in the typekit/boost functions.
This is the patch for gcc that introduced this error:
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01664.html
I didn't see that coming when I created that API. Maybe we can
encapsulate the change such that only
typegen generated code sees it, which would be fine since typegen
typekits are always generated (so no
legacy code to update).
Peter
typegen + __attribute__ ((__packed__))
Hi Sagar,
On Mon, Oct 8, 2012 at 9:37 PM, Sagar Behere <sagar [dot] behere [..] ...> wrote:
> Hello,
>
> I have a struct like
>
> typedef struct __attribute__ ((__packed__))
> {
> uint8_t x;
> int16_t y;
> uint32_t z;
> double p;
> } MyDataType;
>
> This doesn't work with typegen, unless the __attribute__ ((__packed__))
> is removed. The error is
mmm. I vaguely remember 'all is supported except packed and virtuals'.
Sylvain will clarify.
I really like it how you keep rubbing the edges of all this :-)
Now we really need to come to a point where this all works for you.
Peter
PS: Nice blog ! Feels like kst with pictures :-)
typegen + __attribute__ ((__packed__))
On 10/08/2012 10:01 PM, Peter Soetens wrote:
> Hi Sagar,
>
> On Mon, Oct 8, 2012 at 9:37 PM, Sagar Behere <sagar [dot] behere [..] ...> wrote:
>> Hello,
>>
>> I have a struct like
>>
>> typedef struct __attribute__ ((__packed__))
>> {
>> uint8_t x;
>> int16_t y;
>> uint32_t z;
>> double p;
>> } MyDataType;
>>
>> This doesn't work with typegen, unless the __attribute__ ((__packed__))
>> is removed. The error is
> mmm. I vaguely remember 'all is supported except packed and virtuals'.
> Sylvain will clarify.
Actually, since the advent of gccxml, packed is fine for typegen /
typelib. I think we are using packed structs in Rock (not 100% sure
though). The issue here seems to be with the boost serialization.... For
which I have no clue.