struct - Segmentation fault after declaring a variable inside structure -


I am currently working on a project using a network simulator 2. When I add the variable inside the structure , Then the program is compiled but gives me a split mistake during the runtime when I declare the variable as a stable, there is no runtime error. Someone please explain it.

  Structure again_blok {# if __BYTE_ORDER == __BIG_ENDIAN u_int16_t g: 1; U_int16_t prefix: 7; U_int16_t Ris: 2; U_int16_t re_hopcnt: 6; #Elif __BYTE_ORDER == __LITTLE_ENDIN_US_int16_t res: 2; U_int16_t re_hopcnt: 6; U_int16_t g: 1; U_int16_t prefix: 7; # Else # Error "Adjust your & lt; bits / endian.h & gt;" #endif u_int32_t re_node_addr; U_int32_t re_node_secannum; }; # Defined MAX_RE_BLOCKS typedef struct {u_int32_t m: 1; U_int32_t h: 2; U_int32_t Type: 5; U_int32_t Lane: 12; U_int32_t ttl: 6; U_int32_t i: 1; U_int32_t a: 1; U_int32_t s: 1; U_int32_t res1: 3; U_int32_t target_addr; U_int32_t target_seqnum; U_int8_t thopcnt: 6; U_int8_t res2: 2; Structure re_blocks re_blocks [MAX_RE_BLOCKS]; } RE;  

I want to add two float variables to the struct re_block

< P> Using memory debugging tools like valgrind , you can find the place in the code where segfault happens? My guess is that there is some runtime code that takes advantage of the data layout of re_block Stret, for example re_block to type the example (U_int16_t *) and operator - & gt; Instead of using dereferencing as the means of obtaining the first member. Adding the structure to members can change the layout of the data, so the code using such an age can break.


Comments