473,791 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Structure padding warnings when porting to 64 bit

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
3 5165
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
On May 21, 12:18 pm, Erik Wikström <eri...@student .chalmers.sewro te:
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
On 21 Maj, 10:31, abhivg <abhi...@gmail. comwrote:
On May 21, 12:18 pm, Erik Wikström <eri...@student .chalmers.sewro te:
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
"convention al" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3894
by: Amarendra | last post by:
Folks, This structure padding issue is bothering me now, could not locate a satisfactory answer on clc, so here it goes... I have a structure, given below: typedef struct { int flag; char keys; char padding;
2
1857
by: Sachin | last post by:
typdef struct { int i; char ch; }str; str str_var; char x, y; main() { //do nothing
15
2784
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
1
4160
by: pmm | last post by:
hi I am repeating my post here plz excuse i am trying out a UDP packet transfer between a windows machine and a linux I created a structure on both sides (ie on linux and on windows) and I sent using UDP but on the receiving side when I am trying to reform the packet back into structure tis giving me different outputs I assume it is the problem of structure padding I even used pragma pack (1) but still it is not working out for me...
28
3648
by: kyle york | last post by:
Greetings, Why does the C standard require the members of a structure not be re-ordered (6.2.5.20)? Padding is allowed, and platform dependent, which means one cannot rely on the exact layout anyway, so what's the point? Without this restriction the compiler could layout the structure in the most efficient way possible, for some definition of efficient. It would be easy enough to turn this reordering off with a compiler specific...
4
11214
by: junky_fellow | last post by:
Can somebody please tell me about the structure alignment rules ? What I found was that on my system (cygwin running on PC, size of int=4 sizeof long=4, size of long long = 8) the cygwin compiler put the padding after the last member of structure. For eg, struct test { int i; char c; /* no padding required between int and char */ /* 3 byte padding is inserted here, Why ? */
5
2073
by: lovecreatesbea... | last post by:
Does the expression *(int *)&s1 below inside the printf() statement guarantee to refer to the first member of the structure variable s1? I've tried the code and it seems that it works that way. The C standard states this? Thank you very much. #include <stdio.h> struct S{ int m1, m2, m3; };
24
2128
by: karthikbalaguru | last post by:
Hi, I find that the structure padding is not being taken into account while using 'new' operator. Is there a way to enable it ? struct Dataunit { char dataid; int keyid;
12
4807
by: Kislay | last post by:
case 1 : struct s { char c1; // 8 double d; // 8 int i1; // 4 char c2; // 4 int i2; // 4 };
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.