473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how compiler perform Padding in size of structure

Expand|Select|Wrap|Line Numbers
  1. struct st
  2. {
  3.     char a;
  4.     short b;
  5.     char c;
  6. }
what will be size of structue.
Oct 9 '13 #1
3 1188
weaknessforcats
9,208 Expert Mod 8TB
Write a program that displays the size of the struct. Padding is a compiler function so different compilers give different answers.

Mine says 6. What does yours say?
Oct 9 '13 #2
Nepomuk
3,112 Expert 2GB
Mine says "I'm sorry Dave, I'm afraid I can't do that." Wait, is this really a compiler? ;-)
Oct 9 '13 #3
Banfa
9,065 Expert Mod 8TB
Actually it's not just a compiler function, quite often it is related to the platform hardware and on some compilers you can use switches to pragmas to change what padding is used.
Oct 10 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Nitin | last post by:
Hi, Without using sizeof, is there a way to get to know the size of any data type on that OS ... ??? one way I could think of is to take diff of the addresses of two variables defined...
13
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...
10
by: Roman Mashak | last post by:
Hello, All! Could you please explain me how is the padding of 'structure' fields is made? For example: struct { char a1; int a2;
6
by: Laurent | last post by:
Hello, This is probably a dumb question, but I just would like to understand how the C# compiler computes the size of the managed structure or classes. I'm working on this class: public...
20
by: Lalatendu Das | last post by:
hi let's say i have a structure struct test { int A; char B; int C; }; this above structure defination always going to take 16 byte in memeory in whatever manner we align the member variables...
11
by: aaragon | last post by:
Hi everyone. I'm trying to write a class with policy based design (Alexandrescu's Modern C++ Design). I'm not a programmer but an engineer so this is kind of hard for me. Through the use of...
1
by: fdmfdmfdm | last post by:
code like: struct pid_tag{ unsigned int inactive : 1; unsigned int : 1; /* 1 bit of padding */ unsigned int refcount : 6; unsigned int : 0; /* pad to next word boundary...
28
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...
2
by: arunraj2002in | last post by:
Is their any way to find compiler padded structure as output. Ex: struct{ int a; char b; int c;} .. now after padding the structure will be struct{ int a; char b;pad1; pad2; int c;}.. i...
3
by: Martin | last post by:
Is clearing a structure the following way well defined in C89? The structure ACTION contains no floating point or pointer members. Only integral types. My thoughts concern the padding - can and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.