By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,173 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,173 IT Pros & Developers. It's quick & easy.

Structure padding warnings when porting to 64 bit

P: n/a
Hi,

I am trying to port a 32 bit Unix application to 64 bit Windows. While
compiling on Windows I am getting a number of warnings related to
structure padding.
More specifically "warning C4820: 'seqargs' : '4' bytes padding added
after data member 'stop_codon_pos'"

Assuming that there is no pointer arithmetic being done on these
structures, is it ok to safely ignore this warning?

Abhishek

May 21 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 21 Maj, 08:13, abhivg <abhi...@gmail.comwrote:
Hi,

I am trying to port a 32 bit Unix application to 64 bit Windows. While
compiling on Windows I am getting a number of warnings related to
structure padding.
More specifically "warning C4820: 'seqargs' : '4' bytes padding added
after data member 'stop_codon_pos'"

Assuming that there is no pointer arithmetic being done on these
structures, is it ok to safely ignore this warning?
This is probably better answered in a groups dedicated to your
compiler/platform, see the FAQ for suggestions:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

As to your question, it's hard to tell, pointer arithmetic on the
structs themselves will probably be fine, since the compiler knows how
large the struct is. The problems that might arise is if an offset
from the address of the struct is used to access a member. Notice that
this error message would not appear if there weren't some statements
about the alignment of the struct or members thereof and I'll have to
assume that there's some reason for that (though it does not have to
be a good one).

You might want to read the documentation about the warning:
http://msdn2.microsoft.com/en-us/lib...th(vs.80).aspx

--
Erik Wikström

May 21 '07 #2

P: n/a
On May 21, 12:18 pm, Erik Wikström <eri...@student.chalmers.sewrote:
On 21 Maj, 08:13, abhivg <abhi...@gmail.comwrote:
Hi,
I am trying to port a 32 bit Unix application to 64 bit Windows. While
compiling on Windows I am getting a number of warnings related to
structure padding.
More specifically "warning C4820: 'seqargs' : '4' bytes padding added
after data member 'stop_codon_pos'"
Assuming that there is no pointer arithmetic being done on these
structures, is it ok to safely ignore this warning?

This is probably better answered in a groups dedicated to your
compiler/platform, see the FAQ for suggestions:http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

As to your question, it's hard to tell, pointer arithmetic on the
structs themselves will probably be fine, since the compiler knows how
large the struct is. The problems that might arise is if an offset
from the address of the struct is used to access a member. Notice that
this error message would not appear if there weren't some statements
about the alignment of the struct or members thereof and I'll have to
assume that there's some reason for that (though it does not have to
be a good one).

You might want to read the documentation about the warning:http://msdn2.microsoft.com/en-us/lib...th(vs.80).aspx

--
Erik Wikström
Thanks for replying Erik,

By pointer arithmetic, I meant addition of pointers with offsets
(magic numbers). So besides use of pointers and hardcoded offsets, is
there any area where padding might be a problem?
>From what I understood, structure padding is done by the compiler
mainly to speed up memory access.

Sorry about posting my question in the wrong group. Will remember that
from now on.

regards,
Abhishek

May 21 '07 #3

P: n/a
On 21 Maj, 10:31, abhivg <abhi...@gmail.comwrote:
On May 21, 12:18 pm, Erik Wikström <eri...@student.chalmers.sewrote:
On 21 Maj, 08:13, abhivg <abhi...@gmail.comwrote:
Hi,
I am trying to port a 32 bit Unix application to 64 bit Windows. While
compiling on Windows I am getting a number of warnings related to
structure padding.
More specifically "warning C4820: 'seqargs' : '4' bytes padding added
after data member 'stop_codon_pos'"
Assuming that there is no pointer arithmetic being done on these
structures, is it ok to safely ignore this warning?
This is probably better answered in a groups dedicated to your
compiler/platform, see the FAQ for suggestions:http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
As to your question, it's hard to tell, pointer arithmetic on the
structs themselves will probably be fine, since the compiler knows how
large the struct is. The problems that might arise is if an offset
from the address of the struct is used to access a member. Notice that
this error message would not appear if there weren't some statements
about the alignment of the struct or members thereof and I'll have to
assume that there's some reason for that (though it does not have to
be a good one).
You might want to read the documentation about the warning:http://msdn2..microsoft.com/en-us/li...th(vs.80).aspx

Thanks for replying Erik,

By pointer arithmetic, I meant addition of pointers with offsets
(magic numbers). So besides use of pointers and hardcoded offsets,
is there any area where padding might be a problem?
As long as all accesses to the struct and it's members are through
"conventional" means there should be no problem. But as I said, the
warning seems to indicate that someone have specified a specific
alignment requirement on the struct or its members, which seems to
indicate that there's some "unconventional" accesses somewhere.
From what I understood, structure padding is done by the compiler
mainly to speed up memory access.
Yes, but the padding performed by the compiler will not generate
warnings*, that only happens if the programmer have specified some
special alignments requirements on the members/struct (which will
probably slow down memory access since the layout then does not become
the one the compiler would have chosen).

* As an example consider this:
struct Foo {
char a;
int b;
};

On most modern computers there will be three bytes padding after the
char so that the int starts on a 4-byte boundary.

--
Erik Wikström

May 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.