473,853 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Size of pointer to opaque object

``Opaque-pointer representing the ID of an object.
struct _objID;
typedef struct _objID * objectID;''

Hi again. Im using an api that defines an objectID type. The above
represents the
extent of the documentation on it.

The above means that objectID is defined as a pointer to an as yet undefined
class/struct _objID, and, if I understand the term correctly, is opaque in
so far as the actual nature of the _objID class/struct is as yet unknown,
yeah?

My problem is that I need to statically determine the size of an objectID. I
need to now that it occupies the same amount of space as 1,2,3... chars, but
without using sizeof(objectID ). Is it possible? I was thinking that it might
be the same size as char* or something convenient like that.

TIA

Jul 19 '05 #1
12 4734
"Ellarco" <no****@eircom. net> wrote...
``Opaque-pointer representing the ID of an object.
struct _objID;
typedef struct _objID * objectID;''

Hi again. Im using an api that defines an objectID type. The above
represents the
extent of the documentation on it.

The above means that objectID is defined as a pointer to an as yet undefined class/struct _objID, and, if I understand the term correctly, is opaque in so far as the actual nature of the _objID class/struct is as yet unknown,
yeah?

My problem is that I need to statically determine the size of an objectID. I need to now that it occupies the same amount of space as 1,2,3... chars, but without using sizeof(objectID ). Is it possible? I was thinking that it might be the same size as char* or something convenient like that.


The size of a pointer to any object is the same and is the same as
a pointer to void. So, you may use sizeof(void*) for your purposes.

Victor
Jul 19 '05 #2
Ellarco wrote:
....
My problem is that I need to statically determine the size of an objectID. I
need to now that it occupies the same amount of space as 1,2,3... chars, but
without using sizeof(objectID ). Is it possible? I was thinking that it might
be the same size as char* or something convenient like that.


What is stopping you from using sizeof(objectID ) ?

Jul 19 '05 #3

Victor Bazarov wrote:
[...]
My problem is that I need to statically determine the size of an objectID. I
need to now that it occupies the same amount of space as 1,2,3... chars, but
without using sizeof(objectID ). Is it possible?
Yes. Use sizeof(_objID *).
I was thinking that it might
be the same size as char* or something convenient like that.


The size of a pointer to any object is the same and is the same as
a pointer to void.


Change the clinic, Bazarov.

regards,
alexander.
Jul 19 '05 #4

"Victor Bazarov" <v.********@att Abi.com> wrote in message news:L5******** ***********@rwc rnsc51.ops.asp. att.net...
The size of a pointer to any object is the same and is the same as
a pointer to void. So, you may use sizeof(void*) for your purposes.

This is NOT true. A void* is required to hold a converted poitner value to
any object and have the same representation as char*, but it is not necessary
for it to be the same size as all the other pointers.

What is true however, is that the sizeof the pointer to any class has to be
the same size. If this were not true, than creating objects of type pointer
to incomplete classes, wouldn't be possible as the size would not be known.
However, this size can be smaller than sizeof(void*).
Jul 19 '05 #5
WW
Alexander Terekhov wrote:
[SNIP]
The size of a pointer to any object is the same and is the same as
a pointer to void.


Change the clinic, Bazarov.


Change the "cinic", Terekhov.

BTW it can make a whole lot of improvement in communication if you also say
want the point is, not only the insult part. :-)

--
Whitov Wolfov aka Attilov Feherov

Ps: Hota moja ckraju netchevo ne znaju (try to dechipher it, I'va heard it
from my father)
Jul 19 '05 #6

WW wrote:
[...]
BTW it can make a whole lot of improvement in communication if you also say
want the point is, not only the insult part. :-)
What would Ron do here, then?

--
Whitov Wolfov aka Attilov Feherov

Ps: Hota moja ckraju netchevo ne znaju (try to dechipher it, I'va heard it
from my father)


That was probably in reply to your mother asking (with some "elements"
of shouting) your father "Where's The Money Gone?" (or something like
that), I guess. ;-)
Jul 19 '05 #7
WW
Alexander Terekhov wrote:
Whitov Wolfov aka Attilov Feherov

Ps: Hota moja ckraju netchevo ne znaju (try to dechipher it, I'va
heard it from my father)


That was probably in reply to your mother asking (with some "elements"
of shouting) your father "Where's The Money Gone?" (or something like
that), I guess. ;-)


No, actually I was supposed to tell it to the Baltic state(s) borderguards
if they keep asking too many questions. :-)

--
WW aka Attila
Jul 19 '05 #8
Hello,

"Victor Bazarov" <v.********@att Abi.com> wrote in message news:<L5******* ************@rw crnsc51.ops.asp .att.net>...
"Ellarco" <no****@eircom. net> wrote...
``Opaque-pointer representing the ID of an object.
struct _objID;
typedef struct _objID * objectID;''
(...)
Hi again. Im using an api that defines an objectID type. The above
represents the extent of the documentation on it.

The above means that objectID is defined as a pointer to an as yet
undefined class/struct _objID, and, if I understand the term
correctly, is opaque in so far as the actual nature of the _objID
class/struct is as yet unknown, yeah?

My problem is that I need to statically determine the size of an objectID.

Just say 'sizeof (objectID)'.

To know the size of any object, you need the definition of its type.
But if you just want to know the pointer's size, you only need a
forward declaration; it works even with pointers to incomplete types.

(...)
The size of a pointer to any object is the same and is the same as
a pointer to void.


This is true in most platforms, but actually it's implementation
dependent.
++t;
Wagner
Jul 19 '05 #9
Wagner Bruna wrote:
Hello,

"Victor Bazarov" <v.********@att Abi.com> wrote in message news:<L5******* ************@rw crnsc51.ops.asp .att.net>...
The size of a pointer to any object is the same and is the same as
a pointer to void.

This is true in most platforms, but actually it's implementation
dependent.


This is an interesting assertion, and makes me think I don't unserstand
pointers correctly? I thought a pointer contained a memory address, and
that memory addresses had the same size regardless of what that address
is... Otherwise how would it be kosher for me to declare pointers to
undefined Classes. And since most any pointer can be cast to a pointer
to void, a pointer to void would have to be the same size.

Can you give me a counter example where the statement 'the size of a
pointer to any object is the same and [its size] is the same as a
pointer to void' does not hold true?

glen stark

Jul 19 '05 #10

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

Similar topics

1
2656
by: David Gilbert | last post by:
I'm trying to maintain the interface to KQueue for FreeBSD. At one point, the C module stores an opaque object in a C structure such that the opaque pointer can be used later by the application. In Python, I want to say something like: kev = kq.event(kev, 0, 0) and later, this is used by
18
2553
by: Tarundeep | last post by:
hi, let us say it is a 32 bit processor then the size of the pointer is 32 bits. now i want to know what would be the size of the class with vtable pointer in it , that is it has few virtual functions. Since the very first location of the object memory points to the vtbale hence that should be 32 bit.
7
1575
by: Alfonso Morra | last post by:
Straight of the bat, I'll admit this is not a nice solution, it is dangerous (not type safe) etc,etc, I know what the perils are. I don't need a lecture on why what I'm doing is perilous - that is not what I'm after, I want to know *how* I can do it, not *why* I should not do it. I have an opaque abstract data type that has a void* (yes I know its ugly) as one of its members (actually the member is a union - but that's is of little...
18
1814
by: Anand Buddhdev | last post by:
Hi everyone, I'm a C newbie, so please be gentle. I have a program that defines the following things: typedef union { unsigned int I; unsigned char b; } dword;
5
2541
by: Danilo Kempf | last post by:
Folks, maybe one of you could be of help with this question: I've got a relatively portable application which I'm extending with a plugin interface. While portability (from a C perspective) is going to hell just by using dlopen()/LoadLibrary() respectively, I'm still trying to get it as clean as possible. I have a number of different quantums of data and a number of plugins. Since any plugin can (and possibly will) touch any quantum...
2
5312
by: Kurt Ng | last post by:
Hi, y'all. Can anyone help me on this problem? I'm working with a third-party C dll, and I'm having trouble importing into C# the dll's methods that return one of the dll's defined types, which are all defined as opaque pointers. What I tried to do is use IntPtr for the opaque pointer return type, but there seems to be a resulting signature problem.
11
7952
by: quakewang | last post by:
hi, I have define in a head file like this: #define GLUT_BITMAP_9_BY_15 ((void*)2) #define GLUT_BITMAP_8_BY_13 ((void*)3) #define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4) #define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5) then I use the constan in switch, like: switch(font) {
36
7635
by: gert | last post by:
Any comments why char **page doesn't reallocate #include <stdlib.h> void add(char **page,char *line,int n) { char **temp; if(temp=realloc(page,sizeof(char *)*(n+1))) {
4
3511
by: Kenneth Brody | last post by:
I looked at my copy of n1124, and I didn't see anything about this particular situation... What happens if you realloc() to a size of zero? Implementations are allowed to return NULL on malloc(0), and realloc() says it reutrns NULL on failure. (And, on failure, the old pointer has not been freed.) Is it possible for an implementation to return NULL for realloc(ptr,0)
0
9898
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
9748
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
11020
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...
1
10735
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
10358
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...
1
7907
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4549
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
4143
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3180
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.