473,770 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Structure size

I would like to allocate a structure size of 1024 bytes but I want the
compiler to do the calculation for me.

typedef struct
{
int var1;
int var2;
int var3;
char var4[ ?????? ];
} MYSTRUCT;

What I want to do is replace the ?????? something that will automattically
make the total structure 1024 bytes without having to manually count the
bytes of the other members myself.

Is that possible in c++?

Thanks.

Bruce.
Jul 19 '07
56 3175
In article <46************ ***********@new s.uslec.net>,
lr***@superlink .net says...

[ ... ]
It's backwards: the most common setup was 10 6-bit bytes in a 60-bit
word.

No. It was six bit characters. The bytes were 12 bits, the size of a PP
word.
Sorry -- I was using 'byte' as the C and C++ standards do -- to mean the
amount of storage needed for a character. For better or worse, people
have enough different meanings for "byte" that it's hard to be sure
what's meant without specifying...

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 25 '07 #51
LR
Jerry Coffin wrote:
In article <46************ ***********@new s.uslec.net>,
lr***@superlink .net says...

[ ... ]
>>It's backwards: the most common setup was 10 6-bit bytes in a 60-bit
word.
No. It was six bit characters. The bytes were 12 bits, the size of a PP
word.

Sorry -- I was using 'byte' as the C and C++ standards do -- to mean the
amount of storage needed for a character. For better or worse, people
have enough different meanings for "byte" that it's hard to be sure
what's meant without specifying...
I understand, but the C++ standard says "Every byte has a unique
address." and that's a little difficult to apply to a machine (since we
included the 6600) whose CPU addresses 60 bit words. OTOH the PPs
could address 12 bit words.

Of course, we'd have to be careful about dealing with the character
instructions that were added to, I think, the Cyber 70s.

LR

Jul 25 '07 #52
On Jul 24, 11:05 pm, Jerry Coffin <jcof...@taeus. comwrote:
In article <1185310372.905 549.286...@k79g 2000hse.googleg roups.com>,
james.ka...@gma il.com says...
[ 'byte' on Control Data mainframes ... ]
Maybe. It's been a very, very long time. I seem to remember
something about 6 10 bit bytes in a 60 bit word. But that could
be completely wrong.
It's backwards: the most common setup was 10 6-bit bytes in a 60-bit
word.
But of course, an implementation of C couldn't use this
arrangement. (I was just guessing what C would look like on the
machine. The only program I actually ever wrote on it was in
Fortran.)

At any rate, as I said, it was a long time ago, so memory could
be playing any sort of tricks on me. And it didn't seem worth
the bother of looking it up, since I rather doubt I'll have to
write code for that machine anytime in the near future:-).

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 25 '07 #53
In article <46************ ***********@new s.uslec.net>,
lr***@superlink .net says...

[ ... ]
I understand, but the C++ standard says "Every byte has a unique
address." and that's a little difficult to apply to a machine (since we
included the 6600) whose CPU addresses 60 bit words. OTOH the PPs
could address 12 bit words.
C and C++ both require a minimum of 8 bits for characters in any case.

As far as addressing goes, you'd (probably) do about like most C
compilers for the Cray did: a pointer to the word along with a small
integer specifying a character in the word. It's been a long time, but
if memory serves that's roughly how a pointer to char in Pascal 6000 was
implemented.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 25 '07 #54
In article <11************ **********@q75g 2000hsh.googleg roups.com>,
ja*********@gma il.com says...

[ CDC mainframes ... ]
At any rate, as I said, it was a long time ago, so memory could
be playing any sort of tricks on me. And it didn't seem worth
the bother of looking it up, since I rather doubt I'll have to
write code for that machine anytime in the near future:-).
Should you get an irresistible urge to do so, Google for "dtcyber", and
you'll find there's a fairly accurate emulator for it that runs under
Windows...

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 25 '07 #55
LR
Jerry Coffin wrote:
In article <11************ **********@q75g 2000hsh.googleg roups.com>,
ja*********@gma il.com says...

[ CDC mainframes ... ]
>At any rate, as I said, it was a long time ago, so memory could
be playing any sort of tricks on me. And it didn't seem worth
the bother of looking it up, since I rather doubt I'll have to
write code for that machine anytime in the near future:-).

Should you get an irresistible urge to do so, Google for "dtcyber", and
you'll find there's a fairly accurate emulator for it that runs under
Windows...
Is there a COMPASS ng for any questions that come up? ;)

LR
Jul 25 '07 #56
In article <46************ ***********@new s.uslec.net>,
lr***@superlink .net says...

[ ... ]
Is there a COMPASS ng for any questions that come up? ;)
None of which I'm aware...nor (TTBOMK) are there any NGs for Scope, NOS,
NOS/VE, etc.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 25 '07 #57

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3290
by: John | last post by:
Hi all, Can a linked list be a member of a structure? If so, when I add or remove an element from the linked list, the size of the structure will change. Will it cause any problem? Thanks a lot. John
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
10
2314
by: ranjeet.gupta | last post by:
Dear All !! Before i qoute my querry, I will like to qoute my analysis and my Knowledge Struct a { int raw; char data; };
4
3897
by: marco_segurini | last post by:
Hi, From my VB program I call a C++ function that gets a structure pointer like parameter. The structure has a field that contains the structure length and other fields. My problem is that each 'double' fields get 12 bytes instead of 8 so the structure length results wrong. '----Sample
6
5019
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 class MyClass {
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 ? */
15
2239
by: kris | last post by:
Hi I am writing a small program where I need to obtain the actual size of a structure. The programm is as follows struct abc { int j; char k; int i; }*a;
5
3796
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);" I thought that it is very hard to memory map structure array. I need both read and write memory mapped file at both side of C# and C++.
6
4879
by: carles | last post by:
Hi, Here, sample code where a byte array is used to fill a particular structure: fs = File.OpenRead(path); // FileStream BITMAPFILEHEADER bfh = new BITMAPFILEHEADER(); b = new byte;
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10099
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
10037
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
8931
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
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.