Hello All,
I confronted recently with the fact that the size of a struct member
can't be determined with sizeof(Struct:: Member). I'm aware of the
alternative methods to do this, however, I'm interested in the
rationale why the Struct::Member syntax is disallowed.
Thanks, P 5 1770
petschy wrote:
Hello All,
I confronted recently with the fact that the size of a struct member
can't be determined with sizeof(Struct:: Member). I'm aware of the
alternative methods to do this, however, I'm interested in the
rationale why the Struct::Member syntax is disallowed.
Was it even proposed?
If so, what benefits would it bring?
--
Ian Collins.
Was it even proposed?
I don't know.
If so, what benefits would it bring?
I needed the size of a member, without an actual instance and the
syntax 'felt' natural. This could be done, so I just wondered why is
it disallowed.
P
petschy wrote:
I confronted recently with the fact that the size of a struct member
can't be determined with sizeof(Struct:: Member). I'm aware of the
alternative methods to do this, however, I'm interested in the
rationale why the Struct::Member syntax is disallowed.
AFAIK, it will be allowed in the next standard.
On 2 Sep, 22:42, petschy <pets...@gmail. comwrote:
Hello All,
I confronted recently with the fact that the size of a struct member
can't be determined with sizeof(Struct:: Member). I'm aware of the
alternative methods to do this, however, I'm interested in the
rationale why the Struct::Member syntax is disallowed.
Thanks, P
Hi. As Juha pointed out, this is already in the draft for the next
standard, but that does not really answer your question :).
You may find these links interesting: http://www.open-std.org/JTC1/sc22/wg...fects.html#198 http://www.open-std.org/jtc1/sc22/wg...007/n2253.html
DP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rafal Dabrowa |
last post by:
Suppose we have the following structure:
struct foo {
int x, y;
};
Is there a possibility to get sizeof(foo::x) when
no variable of type foo is available ?
I'm not interested with sizeof(int). I want to
|
by: Martin Pohlack |
last post by:
Hi,
I have a funtion which shall compute the amount for a later malloc. In
this function I need the sizes of some struct members without having an
instance or pointer of the struct.
As "sizeof(int)" is legal I assumed "sizeof(struct x.y)" to be legal
too. But is is not:
#include <dirent.h>
|
by: Zero |
last post by:
If we have a structure like:
struct something{
int *a;
int b;
};
We allocate mempry for a using malloc or calloc. The question is when
we want to know the size of the structure, sizeof(struct something),
it will not give us the correct number (i.e. the size of the structure
|
by: Mark A. Odell |
last post by:
Is there a way to obtain the size of a struct element based only upon its
offset within the struct? I seem unable to figure out a way to do this
(short of comparing every element's offset with <offset>). What I would
like to do is create an API something like this:
#include <stddef.h>
struct MemMap
{
unsigned char apple; // 8 bits on my platform
|
by: hilmilho |
last post by:
Hi you,
I'm facing a strange problem, and I don't know what to do. Maybe
someone could help me understand this?
I'm storing IP and Netmask on the struct below.
1st I store IP an print it, its OK, like "127.0.0.1".
Then I store Netmask and it somehow messes the IP's last octet, like
"127.0.0." ...
Check out line comments below, please...
| |
by: Tony Houghton |
last post by:
I'm writing a python program which reads input device events so it needs
to know sizeof(struct timeval). By using the struct module I should be
able to work out sizeof(long) from python, but I can't think of a way to
measure non-fundamental types without including a little bit of C,
which I'd rather avoid.
How safe would I be assuming that
sizeof(struct timeval) == 2 * sizeof(long)
|
by: sean.scanlon |
last post by:
can someone help understand how i can could access a struct field
dymanically like: foo->fields ?
when i try to compile this i get the following error: 'struct pwd' has
no member named 'fields'
is there a way to treat fields as the member name of the struct?
|
by: tom |
last post by:
hiw is calculated size of struct
for example:
struct w1
{
char x1; // 252
__int64 x2; // 8
// should be 260
|
by: sophia.agnes |
last post by:
Dear all,
why the following program is giving o/p as
sizeof(struct emp) = 0
#include<stdio.h>
#include<stdlib.h>
struct emp
|
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,...
|
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...
| |
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |