Struct packing

pull/4/head
Paul Hollinsky 2018-09-20 16:02:40 -04:00
parent 22021bbd83
commit 1f65a03481
2 changed files with 20 additions and 10 deletions

View File

@ -9,6 +9,9 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#pragma pack(push)
#pragma pack(1)
namespace icsneo { namespace icsneo {
class MessageDecoder { class MessageDecoder {
@ -269,4 +272,6 @@ private:
} }
#pragma pack(pop)
#endif #endif

View File

@ -4,26 +4,31 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#pragma pack(push)
#pragma pack(1)
typedef struct { typedef struct {
uint16_t netid; uint64_t timestamp;
uint8_t type;
char header[4];
const uint8_t* data; const uint8_t* data;
size_t length; size_t length;
uint64_t timestamp; char header[4];
char reserved[8]; uint16_t netid;
uint8_t type;
char reserved[9];
} neomessage_t; } neomessage_t;
typedef struct { typedef struct {
uint16_t netid; uint64_t timestamp;
uint8_t type;
uint32_t arbid;
const uint8_t* data; const uint8_t* data;
size_t length; size_t length;
uint64_t timestamp; uint32_t arbid;
char reserved[8]; uint16_t netid;
uint8_t type;
char reserved[9];
} neomessage_can_t; } neomessage_can_t;
#pragma pack(pop)
#ifdef __cplusplus #ifdef __cplusplus
#include "communication/message/include/message.h" #include "communication/message/include/message.h"