Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Make THISFN simpler and more powerful (by taking advantage of some new c++ feature)
Re: Make THISFN simpler and more powerful [message #60925 is a reply to message #60924] |
Tue, 08 October 2024 20:01   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Didier wrote on Tue, 08 October 2024 13:25Hello Lance,
What compilers do with bit field is not covered by a standard and is implementation defined... so they do just about whatever they want.
BUT, something important is missing in you're code ! If you really want everything to be side by side, bit wise, you have to specify PACKED option on you're structs
search the web : __attribute__((packed, aligned(X))) or
This will force the compiler to 'pack' all the bits together not waisting anything : so you will have a stable size.
Note : positionning of the inside the struct is implementation defined ... so some compilers put them in on order, and others the other way around 
==> you're code won't be very portable
Thanks for your reply, Didier.
I am fine with padding. I am having issues with the way MSVC padding this one to unnecessary increase object size.
Also, for union, I expect objects taking same memory address. MSVC failed to deliver. I don't know what the standard says. But it's a tradition dated back to old C.
Are compiler free to reorder data members with the same access privileges? I will have to double check. Thanks again.
|
|
|
 |
 |
Make THISFN simpler and more powerful
By: Lance on Tue, 18 October 2022 21:08
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 November 2022 00:32
|
 |
|
Re: Make THISFN simpler and more powerful
By: Oblivion on Thu, 10 November 2022 06:29
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 November 2022 12:52
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 November 2022 21:41
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Fri, 11 November 2022 02:50
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 08 October 2024 18:38
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 08 October 2024 18:42
|
 |
|
Re: Make THISFN simpler and more powerful
By: Didier on Tue, 08 October 2024 19:25
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 08 October 2024 20:01
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Wed, 09 October 2024 05:59
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Wed, 09 October 2024 16:09
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Wed, 09 October 2024 16:17
|
 |
|
Re: Make THISFN simpler and more powerful
By: Didier on Wed, 09 October 2024 19:32
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 October 2024 14:01
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 October 2024 14:06
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 05 November 2024 02:25
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 05 November 2024 02:33
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 07 November 2024 00:49
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Fri, 29 November 2024 02:30
|
Goto Forum:
Current Time: Thu Jul 03 17:23:40 CEST 2025
Total time taken to generate the page: 0.04007 seconds
|