Questions tagged [packed]

78 questions
2
votes
3 answers

packed structs in tcc

I am trying to do packed struct in tcc C compiller. Code is as follows and __attribute __ tag should be supported: #include #include typedef struct _test_t{ char c; uint16_t i; char d; }…
Nick
  • 9,962
  • 4
  • 42
  • 80
2
votes
1 answer

__attribute__((packed)) and __attribute__((__packed__))

is there a difference between __attribute__((__packed__)) and __attribute__((packed))? And if a struct is packed like this: struct test { int a; short b; } __attribute__((__packed__)) there is never a need to use the packed attribute on each of…
user3035952
  • 301
  • 5
  • 12
2
votes
1 answer

Switching between packed/unpacked structs

I have a lot of configuration data in EEPROM (4KB) which I read out in packed structures. Throughout my firmware I need to read/change these values very frequently, and performance of packed structures is not optimal, so I have a second struct which…
Maestro
  • 9,046
  • 15
  • 83
  • 116
1
vote
4 answers

How to construct a C struct/union with a very odd arrangement of bitfields?

I have the following layout of memory (pseudo code): struct { union { fieldA : 45; struct { fieldB1 : 12; fieldB2 : 33; } } fieldC : 19; } i.e., the memory of field A can be sometimes…
RBH
  • 11
  • 2
1
vote
1 answer

replacing "__attribute__ ((packed))" for compact structures by a standard (portable) C method

Conversion of several values to a byte-string for radio transmission has to avoid unneeded bytes. Using GCC on an ARM target (32 bit) I use "attribute ((packed))". This directive is GCC based (as I read somewhere here) and so not generally portable…
peets
  • 393
  • 1
  • 4
  • 13
1
vote
3 answers

change bit size of packed struct in derived class

The existing code: typedef unsigned int uint; Class A { union xReg { uint allX; struct { uint x3 : 9; uint x2 : 9; uint x1 : 14; }__attribute__((__packed__))…
singleX
  • 375
  • 4
  • 13
1
vote
2 answers

How do I interpret a python byte string coming from F1 2020 game UDP packet?

Title may be wildly incorrect for what I'm trying to work out. I'm trying to interpret packets I am recieving from a racing game in a way that I understand, but I honestly don't really know what I'm looking at, or what to search to understand…
1
vote
0 answers

C: Address trap error when accessing a struct with odd no. of members

I am working with MPLABX with compiler xc16-gcc developing for the 16-bit dsPIC33CH128MP508 microcontroller. I am making code to read from RTC through I2C. I have defined the following structs: typedef struct tagRTC_VL_SECONDSBITS{ uint8_t…
1
vote
1 answer

How can I write packed BCD numbers to an old instrument (Varian FR41 Gaussmeter) with LabVIEW?

I am currently trying to communicate with an old instrument that uses packed BCD numbers only (it's a Varian FR41 Controller Gaussmeter if anyone is familiar). I am using LabVIEW to replicate some old C code that output the BCD code. Below is the C…
Jesse
  • 244
  • 2
  • 15
1
vote
2 answers

Is signed type valid for each element using typedef + packed array (v.s. multidimensional packed array)

I have a question about signed property with multiple packed dimensions which is defined in stages with typedef. Basically, logic signed [1:0][2:0] foo; * foo[0] is not signed (signed is meaningless if you expect signed element) because all entire…
Yunsung Mo
  • 89
  • 1
  • 6
1
vote
3 answers

Packed structures and not packed without code repetition

I have this code: // size probably 4 bytes struct NotPacked { uint16_t first; uint8_t second; }; // size is 3 bytes struct Packed { uint16_t first; uint8_t second; }__attribute__((packed)); I'd like to use the same structure,…
Saturnu
  • 309
  • 1
  • 8
1
vote
0 answers

Using Emmet with pre-packed Ace

I'm trying to use Emmet with the pre-packed version of Ace in a single page. `
bazooka07
  • 23
  • 2
1
vote
1 answer

Why some values make struct.pack and struct.unpack to fail on Windows?

When I use struct.pack() to convert a python integer to C structs (and write it to a file) and then struct.unpack() to reverse the conversion I get usually the original value...but not always. Why? Are there some unmanageable values? Example: import…
jlbmdm
  • 188
  • 6
1
vote
0 answers

gcc C++ explicit alignment gets lost if used through a reference parameter

The following code defines a packed (alignment 1) structure where the dwBug member is not aligned correctly. If such member is assigned to via means of a reference parameter, the assignemnt fails on architectures that do not support unaligned…
numo68
  • 11
  • 1
1
vote
1 answer

Getting embedded PACKED_STRUCT definition to compile under g++

I'm working on a smart meter project, ARM, keil compiler. I want to compile some of the more complex logic under g++ to run regression tests. I'm having a problem with some include files defining the interface to WMBus stack we…
Francis Cagney
  • 301
  • 1
  • 10