justin = {
main feed
,
music
,
code
= {
cockos
,
reaper
,
wdl
,
ninjam
,
jsfx
,
more
}
,
askjf
,
pubkey
};
Ask Justin Frankel
No reasonable question unanswered since 2009!
Suggested topics: programming, music, sleep, coffee, etc.
Note: please do not ask questions about REAPER features, bugs or scheduling, use the
forums
instead.
Name:
Ask:
Human (enter yes):
[
back to index
] | [
unreplied
] | [
replied
] | [
recent comments
] | [
all
]
Question:
Can you explain byte alignment in data structures and why one needs to be cognizant of it (i.e. what does the compiler not do for you)?
Asked by Will (24.234.85.x) on April 11 2013, 10:21pm
Reply on April 12 2013, 12:50am:
Well, I guess you can't always assume that fields in a struct will be next to eachother:
struct foo { int a; double b; };
In this case, depending on compiler/architecture, there might be 4 bytes of padding between a and b, and there might not. Normally it's not much of an issue, except when it is (i.e. if you're pulling something from disk/network and expect it to be packed a certain way, or if you do memcmp(&struct1,&struct2) -- memcmp will look at padding bytes too which could be any value, etc).
Comment:
Your Name:
-- Site Owner's Name:
(for human-verification) Comment:
[
back to index
] | [
unreplied
] | [
replied
] | [
recent comments
] | [
all
]
Copyright 2025 Justin Frankel
.
|
RSS