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

Generic Stack problem


I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:

error C2036: 'void *' : unknown size

How do i overcome this? Any ideas?

TIA,
Scam.

Apr 27 '06 #1
13 5244

Scamjunk wrote:
I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
You're not allowed to dereference a `void *`.
}
}
-------------

and am getting the following error:

error C2036: 'void *' : unknown size

How do i overcome this? Any ideas?


Apr 27 '06 #2
[snips]

On Thu, 27 Apr 2006 03:35:59 -0700, Scamjunk wrote:
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:

error C2036: 'void *' : unknown size


Well... what is a void *? It's a pointer-to-void. What's a void? It is
a non-type. It has no size, no format, it is a black hole from which you
cannot read.

So what's your code do? It takes a void * parameter as value. It then
does:

Stack[*top] = *value;

Hmm. = *value. Assign whatever's in the memory pointed to by value...
but... value is a void pointer; it points to a void, an item with no size,
no actual type, no representation.

How do you expect the compiler to figure out the correct thing to do from
the code, which tells it to retrieve, literally, nothing?

You're going to have to cast, or handle typing a little better or a little
differently, etc.
Apr 27 '06 #3
Scamjunk wrote:

I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:
error C2036: 'void *' : unknown size
How do i overcome this? Any ideas?


By not trying to store a void in an object of type void*

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Apr 27 '06 #4
Got it!

this is the revised code -- for whatever it is worth.

void my_Push(void *value, void **Stack, int *top)
{
if(!(my_IsFull(Stack, top)))
{
(*top)++;
*(Stack + (*top)) = value;
}
}

it compiles alright now. Thanks for the replies.

Apr 28 '06 #5

"Scamjunk" <br*********@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...

I have the following code for a generic stack implementation.

----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------

and am getting the following error:

error C2036: 'void *' : unknown size

How do i overcome this? Any ideas?


Normally, the exact type of 'Stack' and 'value' would be in your function
declaration. Let's take, for example, 'unsigned long' for each:

void Push(unsigned long *value, unsigned long *Stack, int *top)

However, since you used 'void *' and mentioned 'generic' routines, I suspect
you are trying to push and pop different types of values, and perhaps even
structures, onto the 'Stack'. If so, each type except void, can be
represented as an array of unsigned chars. You'll need to redo your generic
routines for unsigned chars (instead of 'void *'). Then you'll need to
convert the data to pushed or popped to unsigned chars, perhaps via casts or
via memcpy etc., before passing to the stack routines. You'll probably also
need to pass the length of each piece of data, since they will vary in size,
in terms of unsigned chars to the push and pop routines.

Make some changes. Try some stuff. Post some more code. IIRC, someone was
working on this about a month ago.
Rod Pemberton
Apr 28 '06 #6
Scamjunk wrote:
Got it!

this is the revised code -- for whatever it is worth.

void my_Push(void *value, void **Stack, int *top)
{
if(!(my_IsFull(Stack, top)))
{
(*top)++;
*(Stack + (*top)) = value;
}
}

it compiles alright now. Thanks for the replies.


Well, it's worth absolutely nothing, because non-Googlers have no idea
what you revised.

Please click on 'More Options' and 'Add Reply' to correctly quote context.

--
"Every prime number in a series as a joke
Made all the patterns clear when I took that final toke"
- - Andrew Poelstra <http://www.wpsoftware.net/blog>
Apr 28 '06 #7

"Andrew Poelstra" <ap*******@shaw.ca> wrote in message
news:eop4g.83366$WI1.68175@pd7tw2no...
Scamjunk wrote:
Got it!

this is the revised code -- for whatever it is worth.

void my_Push(void *value, void **Stack, int *top)
{
if(!(my_IsFull(Stack, top)))
{
(*top)++;
*(Stack + (*top)) = value;
}
}

it compiles alright now. Thanks for the replies.


Well, it's worth absolutely nothing, because non-Googlers have no idea
what you revised.

Please click on 'More Options' and 'Add Reply' to correctly quote context.


Requesting context is one thing. But, saying that non-Googlers have no idea
of what the prior posts were is absurd. I don't use Google. Heck, I don't
even use the high quality newservers provided by my ISP. I just never
bothered becuase it's so easy to find an open one. There are literally
thousands of open newservers in the US, EU, and Asia which are current and
have very good completion (i.e., they didn't loose any meassages). Please
stop spreading myths.

Rod Pemberton
Apr 29 '06 #8
Rod Pemberton wrote:
"Andrew Poelstra" <ap*******@shaw.ca> wrote in message
news:eop4g.83366$WI1.68175@pd7tw2no...
Scamjunk wrote:
Got it!

this is the revised code -- for whatever it is worth.

void my_Push(void *value, void **Stack, int *top)
{
if(!(my_IsFull(Stack, top)))
{
(*top)++;
*(Stack + (*top)) = value;
}
}

it compiles alright now. Thanks for the replies.

Well, it's worth absolutely nothing, because non-Googlers have no idea
what you revised.

Please click on 'More Options' and 'Add Reply' to correctly quote context.


Requesting context is one thing. But, saying that non-Googlers have no idea
of what the prior posts were is absurd. I don't use Google. Heck, I don't
even use the high quality newservers provided by my ISP. I just never
bothered becuase it's so easy to find an open one. There are literally
thousands of open newservers in the US, EU, and Asia which are current and
have very good completion (i.e., they didn't loose any meassages). Please
stop spreading myths.

Rod Pemberton


It's more of a motivation than a truth; I could see what he revised,
because my newsreader has a nice GUI with everything organized.

However, if the people who don't post context believe that it it's only
causing problems to a few people, they won't stop, and we're worse off.

But I agree that c.l.c is /not/ the place for me to be spreading myths.

--
"Every prime number in a series as a joke
Made all the patterns clear when I took that final toke"
- - Andrew Poelstra <http://www.wpsoftware.net/blog>
Apr 29 '06 #9
Andrew Poelstra wrote:
Rod Pemberton wrote:

.... snip ...

Requesting context is one thing. But, saying that non-Googlers
have no idea of what the prior posts were is absurd. I don't use
Google. Heck, I don't even use the high quality newservers
provided by my ISP. I just never bothered becuase it's so easy
to find an open one. There are literally thousands of open
newservers in the US, EU, and Asia which are current and have
very good completion (i.e., they didn't loose any meassages).
Please stop spreading myths.


It's more of a motivation than a truth; I could see what he revised,
because my newsreader has a nice GUI with everything organized.

However, if the people who don't post context believe that it it's
only causing problems to a few people, they won't stop, and we're
worse off.


Contrary to Pembertons claim, most usenet users simply cannot see
previous messages without unholy contortions, even assuming that
such messages ever arrived, and if so that they were not purged
after reading. So meaningless contextless blather is useless.
Nobody in their right mind would run around switching newsservers
to see the missing context.

Around here I connect to the newsserver, download the current crop
of traffic, disconnect, and read/answer/plonk etc. off-line. The
system works very well. It does require the occasional purge of
the complete message history to avoid infinitely growing files.
Meanwhile previously read messages are simply not displayed.

--
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
"We have always known that heedless self-interest was bad
morals. We now know that it is bad economics" - FDR

Apr 30 '06 #10
CBFalconer <cb********@yahoo.com> writes:
Contrary to Pembertons claim, most usenet users simply cannot see
previous messages without unholy contortions, even assuming that
such messages ever arrived, and if so that they were not purged
after reading.


"Most"? This sounds to me like nonsense.
If so, "most" users need to get a better newsreader.
--
"...what folly I commit, I dedicate to you."
--William Shakespeare, _Troilus and Cressida_
Apr 30 '06 #11

"CBFalconer" <cb********@yahoo.com> wrote in message
news:44***************@yahoo.com...
Andrew Poelstra wrote:
Rod Pemberton wrote:
... snip ...

Requesting context is one thing. But, saying that non-Googlers
have no idea of what the prior posts were is absurd. I don't use
Google. Heck, I don't even use the high quality newservers
provided by my ISP. I just never bothered becuase it's so easy
to find an open one. There are literally thousands of open
newservers in the US, EU, and Asia which are current and have
very good completion (i.e., they didn't loose any meassages).
Please stop spreading myths.


It's more of a motivation than a truth; I could see what he revised,
because my newsreader has a nice GUI with everything organized.

However, if the people who don't post context believe that it it's
only causing problems to a few people, they won't stop, and we're
worse off.


Contrary to Pembertons claim, most usenet users simply cannot see
previous messages without unholy contortions,


I use MS Outlook Express - no unholy contortions.
Linux users use ? - no unholy contortions.
even assuming that
such messages ever arrived, and if so that they were not purged
after reading. So meaningless contextless blather is useless.
Nobody in their right mind would run around switching newsservers
to see the missing context.

A while back, you called some other guy a troll after four solid months of
posting. Without any hostility, you _really_ should look for another
newserver.
Around here I connect to the newsserver, download the current crop
of traffic, disconnect, and read/answer/plonk etc. off-line. The
system works very well. It does require the occasional purge of
the complete message history to avoid infinitely growing files.
Meanwhile previously read messages are simply not displayed.


Dialup? Sounds like you're off the grid too. Solar perhaps? Move towards
civilization, buy some "always on" broadband, fix your email client settings
or replace it, and connect to a better newserver. You give the impression
that you're in the dark ages. I mean it sounds like you're using Bitnet or
worse the ancient 1980's dial-in dial-out network Telenet.

If you're running Windows, are you using MS "Outlook Express" for your news
reader? If you're running Linux, are you using Mozilla's "Thunderbird" for
your news reader? If you're not running Linux or Windows, you're part of
the problem that you're experiencing.
Rod Pemberton
Apr 30 '06 #12
Ben Pfaff wrote:
CBFalconer <cb********@yahoo.com> writes:
Contrary to Pembertons claim, most usenet users simply cannot see
previous messages without unholy contortions, even assuming that
such messages ever arrived, and if so that they were not purged
after reading.


"Most"? This sounds to me like nonsense.
If so, "most" users need to get a better newsreader.


I don't think you read the rest of my article. And I have yet to
see a monitor with infinite space on it, so that a reader can
maintain an article and its various predecessors as simultaneously
visible. And that is assuming the predecessors are or have ever
been available.

--
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
"We have always known that heedless self-interest was bad
morals. We now know that it is bad economics" - FDR
Apr 30 '06 #13
CBFalconer <cb********@yahoo.com> writes:
Andrew Poelstra wrote:
Rod Pemberton wrote:
... snip ...

Requesting context is one thing. But, saying that non-Googlers
have no idea of what the prior posts were is absurd. I don't use
Google. Heck, I don't even use the high quality newservers
provided by my ISP. I just never bothered becuase it's so easy
to find an open one. There are literally thousands of open
newservers in the US, EU, and Asia which are current and have
very good completion (i.e., they didn't loose any meassages).
Please stop spreading myths.


It's more of a motivation than a truth; I could see what he revised,
because my newsreader has a nice GUI with everything organized.

However, if the people who don't post context believe that it it's
only causing problems to a few people, they won't stop, and we're
worse off.


Contrary to Pembertons claim, most usenet users simply cannot see
previous messages without unholy contortions, even assuming that


More bullshit? <sniff> Yes indeedy.

"Most" : what a load of old coswallop. Ive used something 8 newsreaders
in the past 10 years and they all had thread context : even for google replies.
such messages ever arrived, and if so that they were not purged
after reading. So meaningless contextless blather is useless.


Since 90% of "no context included replies" are just a "thanks", I'm
amazed so many of your little clique get your panties in such a knot.

May 2 '06 #14

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

Similar topics

2
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress and working in chapter 4, I get the error shown...
3
by: dhussong | last post by:
I'm trying to implement a generic exception handling routine that will write information to a text file at the time the exception occurred. I am using the Microsoft Application Block for Exception...
8
by: Cool Guy | last post by:
From <http://msdn2.microsoft.com/en-us/library/f4a6ta2h(en-US,VS.80).aspx>: | As with the previous use of the Stack<T> class created with the Order | type, another instance of the specialized...
3
by: snesbit | last post by:
I have a structure called SearchAreaListItem. The structure has some properties. The application implements this as a collection.generic.list(of SearchAreaListItem) I load the collection up ...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
0
by: Mikkel Blanné | last post by:
I haven't been able to find any references to using this combination of technologies (remoting + generic methods + method overloading). I don't think the problem has to do with C#, but I couldn't...
4
by: Mahmoud Al-Qudsi | last post by:
Hi all, I'm working on a C# project, and at some point I'm needing to pass the same stack to multiple functions. I found out the hard way that when I poss a stack by value it doesn't actually...
11
by: Bob Altman | last post by:
Hi all, I want to write a generic class that does this: Public Class X (Of T) Public Sub Method(param As T) dim x as T = param >3 End Sub End Class
6
by: ziamughal | last post by:
Dear Sir i have made a stack in which i can store the strings the whole code is below , i want to make this stack a generic stack, what i need to do, look at the code and give me some suggestions...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.