473,406 Members | 2,336 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,406 software developers and data experts.

void pointer

what is a void pointer?

Sep 7 '05 #1
5 7239

"Niks" <nb*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
what is a void pointer?


void* MyPointer;

Sep 7 '05 #2
Niks wrote:
what is a void pointer?


You mean a pointer to void?

A generic pointer, a plain address. That type is returned from 'malloc'
function and from 'operator new', and is accepted by 'operator delete'
as an argument. Usually a pointer to void is used to hold a pointer to
an object of any type or of an unknown type. Has the same alignment
requirements and the same representation as 'char*'. Along with the
requirement that 'void*' can hold a pointer to any object comes the
standard conversion from a pointer to object to a pointer to void. That
conversion is implicit and the reverse can be done using 'static_cast'.

V
Sep 7 '05 #3

Victor Bazarov wrote:
Niks wrote:
what is a void pointer?


You mean a pointer to void?

A generic pointer, a plain address. That type is returned from 'malloc'
function and from 'operator new', and is accepted by 'operator delete'
as an argument. Usually a pointer to void is used to hold a pointer to
an object of any type or of an unknown type. Has the same alignment
requirements and the same representation as 'char*'. Along with the
requirement that 'void*' can hold a pointer to any object comes the
standard conversion from a pointer to object to a pointer to void. That
conversion is implicit and the reverse can be done using 'static_cast'.

V


Can it hold (is it big enough to hold) a pointer to a member function?
I know that the pointers to member functions are implementation
specific, but I was wondering if the standard says anything about this.

thanks,
Dan

Sep 7 '05 #4
Dan Cernat wrote:
Victor Bazarov wrote:
Niks wrote:
what is a void pointer?
You mean a pointer to void?

A generic pointer, a plain address. That type is returned from 'malloc'
function and from 'operator new', and is accepted by 'operator delete'
as an argument. Usually a pointer to void is used to hold a pointer to
an object of any type or of an unknown type. Has the same alignment
requirements and the same representation as 'char*'. Along with the
requirement that 'void*' can hold a pointer to any object comes the
standard conversion from a pointer to object to a pointer to void. That
conversion is implicit and the reverse can be done using 'static_cast'.

V

Can it hold (is it big enough to hold) a pointer to a member function?


No. Only a pointer to an object.
I know that the pointers to member functions are implementation
specific, but I was wondering if the standard says anything about this.


It says "A void* shall be able to hold any object pointer."

V
Sep 7 '05 #5

Victor Bazarov wrote:
Dan Cernat wrote:
Victor Bazarov wrote:
[...]
It says "A void* shall be able to hold any object pointer."

V


Thanks,
Dan

Sep 7 '05 #6

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

Similar topics

15
by: Stig Brautaset | last post by:
Hi group, I'm playing with a little generic linked list/stack library, and have a little problem with the interface of the pop() function. If I used a struct like this it would be simple: ...
6
by: bob_jenkins | last post by:
{ const void *p; (void)memset((void *)p, ' ', (size_t)10); } Should this call to memset() be legal? Memset is of type void *memset(void *, unsigned char, size_t) Also, (void *) is the...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
9
by: Juggernaut | last post by:
I am trying to create a p_thread pthread_create(&threads, &attr, Teste, (void *)var); where var is a char variable. But this doesnt't work, I get this message: test.c:58: warning: cast to pointer...
5
by: Stijn van Dongen | last post by:
A question about void*. I have a hash library where the hash create function accepts functions unsigned (*hash)(const void *a) int (*cmp) (const void *a, const void *b) The insert function...
56
by: maadhuu | last post by:
hello, this is a piece of code ,which is giving an error. #include<stdio.h> int main() { int a =10; void *p = &a; printf("%d ", *p ); //error....why should it //be an error ?can't the...
16
by: aegis | last post by:
Given the following: int a = 10; int *p; void *p1; unsigned char *p2; p = &a;
27
by: Erik de Castro Lopo | last post by:
Hi all, The GNU C compiler allows a void pointer to be incremented and the behaviour is equivalent to incrementing a char pointer. Is this legal C99 or is this a GNU C extention? Thanks in...
49
by: elmar | last post by:
Hi Clers, If I look at my ~200000 lines of C code programmed over the past 15 years, there is one annoying thing in this smart language, which somehow reduces the 'beauty' of the source code...
28
by: junky_fellow | last post by:
Guys, Consider a function func(void **var) { /* In function I need to typecast the variable var as (int **) I mean to say, I need to access var as (int **) }
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.