473,795 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flexible array member

Can someone help me understand what flexible array members exactly are,
how they behave and how could them be implemented by a i386?
Also I didn't understand the two exceptions that the standards talks
about (when talking about ignoring the flexible array member). Please
help me.

--
Devaraja (Xdevaraja87^gm ail^c0mX)
Linux Registerd User #338167
http://counter.li.org
Nov 15 '05 #1
2 2997

DevarajA 写道:
Can someone help me understand what flexible array members exactly are,
how they behave and how could them be implemented by a i386?
Also I didn't understand the two exceptions that the standards talks
about (when talking about ignoring the flexible array member). Please
help me.

--
Devaraja (Xdevaraja87^gm ail^c0mX)
Linux Registerd User #338167
http://counter.li.org


They allow for the last member of a struct to be an incomplete type
until an oject
of such a type is allocated. As such, there is a lack of information to
determine
the size of the struct. This means that when you allocate an object
that will
represent this struct type, you can provide the information about the
size that
the struct object needs to be. Take for example a message queue system,
where
the size of the message has not yet been determined. Where you choose
to not
place constraints on a message size, you could use a flexible array
member to
represent this undetermined size.

i386 is conceptually irrelevant to the implementation of flexible array
members.
This is because an implementation that adheres to the 9899:1999
specification
is fundamentally a virtual machine. It need not care about the
underlying hardware.

As for the two exceptions, care to provide a section number from the
standard?

--
aegis

Nov 15 '05 #2
aegis ha scritto:
DevarajA 写道:

Can someone help me understand what flexible array members exactly are,
how they behave and how could them be implemented by a i386?
Also I didn't understand the two exceptions that the standards talks
about (when talking about ignoring the flexible array member). Please
help me.

--
Devaraja (Xdevaraja87^gm ail^c0mX)
Linux Registerd User #338167
http://counter.li.org

They allow for the last member of a struct to be an incomplete type
until an oject
of such a type is allocated.


Ok, thanks.

[cut] As for the two exceptions, care to provide a section number from the
standard?


6.7.2.16 (it should be page 103, but I'm not sure because I've got it on
pdf)

--
Devaraja (Xdevaraja87^gm ail^c0mX)
Linux Registerd User #338167
http://counter.li.org
Nov 15 '05 #3

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

Similar topics

3
5847
by: Kaz Kylheku | last post by:
Given some class C with array T x, is it possible to get a pointer-to-data-member to one of the elements? &C::x gives us a pointer-to-member-array: T (C::*). But I just want to get a T C::* pointing to a selected array element, so that I can later use an instance c of that class to pick out that array element: c->*ptr. This syntax, for instance, doesn't work: &C::x. My compiler thinks
10
6696
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
2
2131
by: Simon Morgan | last post by:
I hope this isn't OT, I looked for a newsgroup dealing purely with algorithms but none were to be found and seeing as I'm trying to implement this in C I thought this would be the best place. I have an array of structs containing data which I'd like to output ordered based on the value of a single member. I was wondering if there is a relatively simple way of doing this without actually modifying the structure of the array? I had a...
2
10326
by: Christopher Benson-Manica | last post by:
Is the following program conforming under C99? #include <stdio.h> typedef struct foo { int bar; int baz; } foo; foo foos={
5
6467
by: Varangian | last post by:
ImageButton ship; ship = new ImageButton; for (int i=0; i<5; i++) { ship.ImageUrl = pathofImage; ship.ID = "ShipNo" + i.ToString(); ship.Click += new ImageClickEventHandler(this.ImageBtn_Click); this.Form1.Controls.Add(ship); }
8
2474
by: ulyses | last post by:
I'm trying to put pointer to flexible array of structures in other structure. I want to have pointer to array of pixels in screen structure. Here is mine code, but I think it isn't quite all right: struct pixel { int x; int y; int color; };
20
1818
by: mechanicfem | last post by:
I thought (as they're in c99) that flexible arrays were there for a number of reasons - but I also thought they'd be great for stepping into structures (say) that were aligned in memory after (say) a header struct, e.g.: struct element { int a; int b; };
2
2273
by: tobiasoed | last post by:
Hello, I want to do something similar to this: #include <stdlib.h> struct coord { double val; double err; };
3
3892
by: Hallvard B Furuseth | last post by:
to find the required alignment of a struct, I've used #include <stddef.h> struct Align_helper { char dummy; struct S align; }; enum { S_alignment = offsetof(struct Align_helper, align) };
0
9672
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10438
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
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
10164
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
9042
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 projectplanning, coding, testing, and deploymentwithout 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
6780
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.