473,386 Members | 1,745 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,386 software developers and data experts.

I don't understand a past thread (help)

friends,
As I was going through a set of past thread I have some doubts in that.
The link to the thread is:

http://groups.google.co.in/groups?hl...41afc61&rnum=1
I considered the void pointer is the correct way to use generic type
in C programming(correct me if I am wrong.)
In the above thread is not it possible to create a
function using void pointer (as Default User suggested)? No body said
yes or no to his suggestion. Am I misunderstanding the concept of
generic type and void pointer?

--
"Combination is the heart of chess"
A.Alekhine
Mail to:
sathyashrayan25 AT yahoo DOT com
(remove the AT and DOT)

Nov 14 '05 #1
5 1338
sathya_me <sa*******@nomail.com> wrote:
friends,
As I was going through a set of past thread I have some doubts in that.
The link to the thread is:

http://groups.google.co.in/groups?hl...41afc61&rnum=1 I considered the void pointer is the correct way to use generic type
in C programming(correct me if I am wrong.)
In the above thread is not it possible to create a
function using void pointer (as Default User suggested)? No body said
yes or no to his suggestion. Am I misunderstanding the concept of
generic type and void pointer?


The original problem was that the OP (Walter L. Preuninger) wanted to
pass _only_ a void pointer to a funtion and then retrieve information
about the type of the variable of what that pointer was pointing to.
And that's what is impossible, once you only have a void pointer
you can't figure out from that void pointer alone what knd of type
of variable it's pointing to. If you need that information you have
to pass it to the function together with the pointer. One of the
things proposed (by "Default User" aka Brian Rodenborn) was to use a
structure that contains the pointer as well as an integer with type
information and pass that to the function, which is of course a
possible solution (not getting a reply to a suggestion can, at least
in this group, usually be taken to mean that nobody finds any fault
with it;-). So, yes, a void pointer is as generic a pointer as it can
get, but as such it doesn't convey some often important bit of infor-
mation, the type of what's poined to, and if that is needed it must
be supplied by other means.
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #2


Je***********@physik.fu-berlin.de wrote:
sathya_me <sa*******@nomail.com> wrote:

friends,
As I was going through a set of past thread I have some doubts in that.
The link to the thread is:

http://groups.google.co.in/groups?hl...41afc61&rnum=1

I considered the void pointer is the correct way to use generic type
in C programming(correct me if I am wrong.)
In the above thread is not it possible to create a
function using void pointer (as Default User suggested)? No body said
yes or no to his suggestion. Am I misunderstanding the concept of
generic type and void pointer?


The original problem was that the OP (Walter L. Preuninger) wanted to
pass _only_ a void pointer to a funtion and then retrieve information
about the type of the variable of what that pointer was pointing to.

I don't find any intention (retrieve information of the void*) in the
OP's post and thread
which follows. I am still miss something?
(Is section 4.9 of FAQ covers above of your definition?)
And that's what is impossible, once you only have a void pointer
you can't figure out from that void pointer alone what knd of type
of variable it's pointing to. If you need that information you have
to pass it to the function together with the pointer. One of the
things proposed (by "Default User" aka Brian Rodenborn) was to use a
structure that contains the pointer as well as an integer with type
information and pass that to the function, which is of course a
possible solution (not getting a reply to a suggestion can, at least
in this group, usually be taken to mean that nobody finds any fault
with it;-). So, yes, a void pointer is as generic a pointer as it can
get, but as such it doesn't convey some often important bit of infor-
mation, the type of what's poined to, and if that is needed it must
be supplied by other means.
^^^^^^^^^^^


Any link or FAQ for *other means* (I did went through but I did not find
the above).

--
"Combination is the heart of chess"
A.Alekhine
Mail to:
sathyashrayan25 AT yahoo DOT com
(remove the AT and DOT)

Nov 14 '05 #3
sathya_me <sa*******@nomail.com> wrote:
Je***********@physik.fu-berlin.de wrote:
sathya_me <sa*******@nomail.com> wrote:

As I was going through a set of past thread I have some doubts in that.
The link to the thread is:

http://groups.google.co.in/groups?hl...41afc61&rnum=1

I considered the void pointer is the correct way to use generic type
in C programming(correct me if I am wrong.)
In the above thread is not it possible to create a
function using void pointer (as Default User suggested)? No body said
yes or no to his suggestion. Am I misunderstanding the concept of
generic type and void pointer?
The original problem was that the OP (Walter L. Preuninger) wanted to
pass _only_ a void pointer to a funtion and then retrieve information
about the type of the variable of what that pointer was pointing to.

I don't find any intention (retrieve information of the void*) in the
OP's post and thread
which follows. I am still miss something?
(Is section 4.9 of FAQ covers above of your definition?)


To make sure we're talking about the same thing: I was refering to the
thread with the subject "Way to determine type of variable?" - at least
that's what I found under the URL you posted. And it starts with the
question

"Walter L. Preuninger II" wrote: I would like to write a generic procedure that will take string or numeric
variables. I can not think of a way to make this more clear except to show
what I want.

int i=7;
char *s="/etc/filesystems";
generic(i);
generic(s);


So what he was more or less looking for a way to give some argument of
unspecified type to a function and, if possible, have the function
detect the type from what it got. Now, the only kind of appropriately
unspecified type is a void pointer, but it's lacking the type informa-
tion needed to print its value, so the kind of generic function he was
looking for isn't possible.
with it;-). So, yes, a void pointer is as generic a pointer as it can
get, but as such it doesn't convey some often important bit of infor-
mation, the type of what's poined to, and if that is needed it must
be supplied by other means.
^^^^^^^^^^^

Any link or FAQ for *other means* (I did went through but I did not find
the above).


Other means just means that you have to pass not only a void pointer
to the function but also some information about the type of what that
pointer points to. That can be done e.g. by passing it an additional
integer, with the value telling the function something about the type,
or e.g. a printf()-kind of format string or whatever other method you
can come up with - you could also use a global variable that always
gets set before the function call to some value representing the type
of the void pointer (but that would probably a rather ugly design).
"Default User"'s proposal was one of the possible ways to do this by
passing the function a structure that holds both a void pointer and
an integer, indicating what kind of type the pointer is pointing to.

But I get the feeling that I am misunderstanding you, so could you
perhaps try to explain again what exactly your question is? I seem
to be too dense to get it;)
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #4
sathya_me wrote:
friends,
As I was going through a set of past thread I have some doubts in
that. The link to the thread is:

http://groups.google.co.in/groups?hl...e=off&th=e0ab5
65b941afc61&rnum=1
The guy who wanted function overloading. I vaguely remember it.
I considered the void pointer is the correct way to use generic type
in C programming(correct me if I am wrong.)
It is a way.
In the above thread is not it possible to create a
function using void pointer (as Default User suggested)?
Of course it's possible. Just not all that handy. Personally, I
consider a void pointer with type information preferable to a union
with type information, but both are ways to go about it. However, just
having a function with a void* won't do it for you.

void func(void *data)
{
/* what's data's type? nobody knows! */
}
No body said yes or no to his suggestion.
No doubt they were stunned by its brilliant simplicity (or simple
brilliancy). Or maybe so pedestrian and obvious it merited no comment.
Am I misunderstanding the concept of generic type and void pointer?


I don't know, are you? You'd need to ask some specific questions about
generic programming.

Brian Rodenborn
Nov 14 '05 #5
sathya_me wrote:
.... snip ..
I considered the void pointer is the correct way to use generic
type in C programming(correct me if I am wrong.)


Take a look at hashlib.c and the usage examples, found at:

<http://cbfalconer.home.att.net/download/hashlib.zip>

for examples of the use of void* pointers and opaque data
objects. This separates the module interface from its
implementation as far as possible. As long as .h file is not
altered the .c file can be revised freely. Inasmuch as I wrote it
it obviously is a close approximation to perfection :-) There has
only been one bug-report (fixed) since publishing it.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 14 '05 #6

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

Similar topics

4
by: Robert Blackwell | last post by:
I'm trying to follow along in class typing exactly whats put on the board. using System; namespace SchoolStuff { public class UseCalcPay
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
61
by: John Baker | last post by:
When declaring an integer, you can specify the size by using int16, int32, or int64, with plain integer being int32. Is integer the accepted default in the programming community? If so, is...
4
by: Jeff Stewart | last post by:
Specifically, I don't understand the parameter that Synclock accepts. How is a reference type a lockable entity? What -is- a reference type? Is it a number? Is it a value at a specific memory...
7
by: Kevin Frey | last post by:
Using .NET 1.1. We have a mixed-mode assembly written in Managed C++ that we are using from an ASP.NET application that has been coded using C#. The mixed-mode assembly has its own...
4
by: ljh | last post by:
I am trying to run some pretty simple code that monitors a folder for changes (copied the example at http://www.codeproject.com/dotnet/folderwatcher.asp). But, when I try and update a textbox...
3
by: smorrey | last post by:
Howdy folks, I recently purchased a book on C++ MUD creation and it features alot of nifty tidbits. The book is MUD GAME PROGRAMMING by Ron Penton Publisher: Premier Press Anyways of...
4
by: Peyman | last post by:
Hi, I was reading the source code of an implementation of STL by HP company 1994, and Silicon Graphics Computer Systems, Inc. 1996, 1997. Which I found that for implementing a Linked List, they...
7
by: sara | last post by:
I have a friend doing some pro-bono work for a non-profit that does job training for distressed kids under DCSS care. He asked me for code to do the following (he's using A2003). I can't find...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...

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.