How to define multiple versions of a structure?

That is close to how we did the ticker plant for global trading.

No. A struct in c++ is EXACTLY the same thing as a class, except member data and methods are by default private in a class, and public in a struct. They BOTH have constructors.

I really need to think carefully before I respond to these things :slight_smile:

my understanding of the "undefined behavior" is that there is a problem if the ptrs are word aligned. A multi-byte sub-field won't be accessed properly if it straddles a word boundary where word is the size of the address bus.

while i haven't ever come across a case where is doesn't work, there's no guarantee that it will always work.

It's about much more than data alignment. It's about assumptions and decisions that the compiler makes while compiling and optimizing your source code. If your code violates the rules of the language, those assumptions and decisions, and hence the resultant object code become invalid.

i looked at Torvalds memcpy() code that presumably addresses the issue and didn't see anything exotic.

what kinds of assumption/decisions does the compiler make?

not sure what "invalid" means. There's no compiler error. i've not not worked on a processor where this doesn't work. i saw this approach used in XINU ethernet code.

it's simply not guaranteed to work in "any" case, in other words, there's no guarantee that the course will work on any processor. you shouldn't "port" code written like this to another architecture

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.