Topic: Stupid Computer gives error


Author: pjnagel@dos-lan.cs.up.ac.za (P.J Nagel)
Date: Mon, 5 Sep 1994 23:07:57 GMT
Raw View
In article <33v57k$iv1@hq.hq.af.mil> damoore@pafosu1 (Dale A Moore) writes:
>        I've been trying to get this stupid program to run forever
>and each time I get an error I've been deleteing lines.  So, now
>I'm to the point of only having 3 executable lines.  Can someone
>help??????

>The compiler then very rudely says "Cannot convert 'void *' to
>        'char *'.
>What!!!???  If it wants to tell me something why doesn't it say it
>in English?  Obviously, I don't get paid for programming...just
>torturing myself with it.  Someone - Please help.

To avoid similar problems, follow these simple guidelines:

- Make an effort to learn the language you use.

- Often, compiler diagnostics pinpoint the exact source of your problem.

  If you don't understand a compiler error, brush up on your knowledge
  of the language you are using, lest you create the impression of
  being more stupid than your computer.

- If you still have a problem, carefully select an appropriate newsgroup
  for guidance.

  You will have to think for this one. Not every newsgroup with  "C++"
  in it's name is relevant to your C++ problems. For example, comp.std.c++
  is devoted to standardizing the C++ language and is full of brainy geeks.
  You might accidentally look like a moron in their presence.

  You would be better served in comp.lang.c++. Better yet, as the code you
  posted did not contain a single construct specific to C++, go to the
  comp.lang.c newsgroup.

- When you post simply state your question. Avoid any implication that
  "I am a genius - it's my computer that's stupid and my compiler that is
  bug-ridden".

  Otherwise, you might just attract the attention of some rude person who
  is eager to chew your head off.

Hope this helps.

        ,_
        /_)              /| /
       /   i e t e r    / |/ a g e l
       The Platinum Puma




Author: olaf@cwi.nl (Olaf Weber)
Date: Tue, 6 Sep 1994 06:41:59 GMT
Raw View
Concerning the conversion of a void* to a char*, P.J Nagel writes:

>   You would be better served in comp.lang.c++. Better yet, as the code you
>   posted did not contain a single construct specific to C++, go to the
>   comp.lang.c newsgroup.

In C, a void* can be converted into a char* without a cast, in C++
this is forbidden.  So the code _is_ C++ specific, and comp.lang.c++
is the correct group.  (Followups have been set there.)

Aside from this nit, Pieter's points are well worth remembering.

-- Olaf Weber




Author: michaelc@lna.logica.com
Date: Wed, 31 Aug 1994 13:38:32 GMT
Raw View
>>>>> "damoore" == Dale A Moore <damoore@pafosu1> writes:

    damoore>  I've been trying to get this stupid program to run forever

It will take you a very long time to get this program to run forever.

    damoore>  char far *base_address = MK_FP(0xA000:0000);
    damoore> The compiler then very rudely says "Cannot convert 'void *' to
    damoore>  'char *'.

You need a cast.

                char far *base_address = (char far*) MK_FP(0xA000:0000);

    damoore> What!!!???  If it wants to tell me something why doesn't it say it
    damoore> in English?

What it should have said is, "The MK_FP macro expands to an expression which
has the type `void*'.  You have tried to use that expression in a context that
requires an expression of type `char far*'.  The evolving C++ standard does
not allow implicit conversions from `void*', unlike the C standard.  As a
result of this boneheaded mistake, I'm generating code that will make your
stupid program run forever."

Michael.




Author: rich@kastle.com (Richard Krehbiel)
Date: Wed, 31 Aug 1994 15:12:26 GMT
Raw View
In article <33v57k$iv1@hq.hq.af.mil> damoore@pafosu1 (Dale A Moore) writes:

>   void main(void)   {
>    char far *base_address = MK_FP(0xA000:0000);
>    printf("The contents of this location are: %d\n",*base_address);
>    getch();
>   }
>   The compiler then very rudely says "Cannot convert 'void *' to
>    'char *'.
>   What!!!???  If it wants to tell me something why doesn't it say it
>   in English?  Obviously, I don't get paid for programming...just
>   torturing myself with it.  Someone - Please help.

What? Indeed!  Doesn't the C standard say that void* silently converts
to any other pointer type?




Author: rich@kastle.com (Richard Krehbiel)
Date: Wed, 31 Aug 1994 15:13:44 GMT
Raw View
In article <33v57k$iv1@hq.hq.af.mil> damoore@pafosu1 (Dale A Moore) writes:

>   void main(void)   {
>    char far *base_address = MK_FP(0xA000:0000);
                                             ^
I believe this must be a comma.

>    printf("The contents of this location are: %d\n",*base_address);
>    getch();
>   }
>   The compiler then very rudely says "Cannot convert 'void *' to
>    'char *'.

...though that message is a mystery.




Author: b91926@fnclub.fnal.gov (David Sachs)
Date: 31 Aug 1994 16:44:06 GMT
Raw View
In article <RICH.94Aug31101226@standalone.kastle.com>, rich@kastle.com (Richard Krehbiel) writes:
|> In article <33v57k$iv1@hq.hq.af.mil> damoore@pafosu1 (Dale A Moore) writes:
|>
|> >   void main(void)   {
|> >    char far *base_address = MK_FP(0xA000:0000);
|> >    printf("The contents of this location are: %d\n",*base_address);
|> >    getch();
|> >   }
|> >   The compiler then very rudely says "Cannot convert 'void *' to
|> >    'char *'.
...
|> What? Indeed!  Doesn't the C standard say that void* silently converts
|> to any other pointer type?

This is one of the incompatibilitites between the C and C++ languages. While the code example is perfectly legal C language code, C++ requires an explicit cast.




Author: rjl@f111.iassf.easams.com.au (Rohan LENARD)
Date: 1 Sep 1994 10:28:16 +1000
Raw View
In article <RICH.94Aug31101226@standalone.kastle.com>,
Richard Krehbiel <rich@kastle.com> wrote:
Richard>In article <33v57k$iv1@hq.hq.af.mil> damoore@pafosu1 (Dale A Moore) writes:
Richard>
Richard>>   void main(void)   {
Richard>>    char far *base_address = MK_FP(0xA000:0000);
Richard>>    printf("The contents of this location are: %d\n",*base_address);
Richard>>    getch();
Richard>>   }
Richard>>   The compiler then very rudely says "Cannot convert 'void *' to
Richard>>    'char *'.
Richard>>   What!!!???  If it wants to tell me something why doesn't it say it
Richard>>   in English?  Obviously, I don't get paid for programming...just
Richard>>   torturing myself with it.  Someone - Please help.
Richard>
Richard>What? Indeed!  Doesn't the C standard say that void* silently converts
Richard>to any other pointer type?


Well the ANSI C++ standard doesn't - and the user did ask in comp.std.c++

Regards,
 Rohan
--
----------------------------------------------------------------------------
rjl@iassf.easams.com.au | All quotes can be attributed to my automated quote
Rohan Lenard            | writing tool.  Yours for just $19.95; and if you
+61-2-367-4555          | call now you'll get a free set of steak knives ...




Author: Eugene M. Hutorny <eugene@ksf.kiev.ua>
Date: Thu, 1 Sep 1994 09:40:19 GMT
Raw View
Hi Dale,
You tried to asign value which type is 'void *' to variable of
type 'char far *'. Compiler could not do it by itself because
size of '*(char far *)' is 1 and size of '*(void *)' is unknown.
You ned to use obvious type conversion:

void main(void)   {
        char far *base_address = (char far*) MK_FP(0xA000:0000);
        printf("The contents of this location are: %d\n",*base_address);
        getch();
}






Author: damoore@pafosu1 (Dale A Moore)
Date: 30 Aug 1994 11:29:56 GMT
Raw View
Hi All,
 I've been trying to get this stupid program to run forever
and each time I get an error I've been deleteing lines.  So, now
I'm to the point of only having 3 executable lines.  Can someone
help??????


void main(void)   {
 char far *base_address = MK_FP(0xA000:0000);
 printf("The contents of this location are: %d\n",*base_address);
 getch();
}
The compiler then very rudely says "Cannot convert 'void *' to
 'char *'.
What!!!???  If it wants to tell me something why doesn't it say it
in English?  Obviously, I don't get paid for programming...just
torturing myself with it.  Someone - Please help.


--
 Dale Moore
 Email -   damoore@pafosu1.hq.af.mil





Author: hwolfe@corona (Herb Wolfe)
Date: 30 Aug 1994 18:44:10 GMT
Raw View
Dale A Moore (damoore@pafosu1) wrote:
: Hi All,
:  I've been trying to get this stupid program to run forever
: and each time I get an error I've been deleteing lines.  So, now
: I'm to the point of only having 3 executable lines.  Can someone
: help??????

maybe. this isn't exactly the place for this but i'll try anyways.
why keep deleting lines, though? why not comment them out?

: void main(void)   {
:  char far *base_address = MK_FP(0xA000:0000);

should this be an assignment? if so, you need another =

:  printf("The contents of this location are: %d\n",*base_address);
:  getch();
: }

: The compiler then very rudely says "Cannot convert 'void *' to
:  'char *'.
: What!!!???  If it wants to tell me something why doesn't it say it
: in English?  Obviously, I don't get paid for programming...just
: torturing myself with it.  Someone - Please help.

looks like english to me. btw, what do you get paid for if not programming?

herb




Author: allen@ariel.com (Marc L. Allen)
Date: 30 Aug 1994 18:41:31 GMT
Raw View
Dale A Moore (damoore@pafosu1) wrote:

> void main(void)   {
>  char far *base_address = MK_FP(0xA000:0000);
>  printf("The contents of this location are: %d\n",*base_address);
>  getch();
> }
> The compiler then very rudely says "Cannot convert 'void *' to
>  'char *'.

Well.. without actually TRYING the code, I would guess that the problem
is in your initialization of base_address.  Maybe if you try casting it
explicitly?

 char far *base_address = (char *) MK_FP(0xA000:0000);

Just a though.  Btw, the compiler should tell you exactly which line is
causing the problem.

Marc
allen@chesapeake.rps.slb.com




Author: allen@ariel.com (Marc L. Allen)
Date: 30 Aug 1994 20:08:55 GMT
Raw View
Herb Wolfe (hwolfe@corona) wrote:

> : void main(void)   {
> :  char far *base_address = MK_FP(0xA000:0000);

> should this be an assignment? if so, you need another =

Huh?  I'm not familiar with an MK_FP macro, but I assume it takes a real
mode address description and returns a pointer to the address.  Why do I need
a second equals sign?

Marc





Author: osinski@porter.cs.nyu.edu (Ed Osinski)
Date: 30 Aug 1994 21:26:34 GMT
Raw View
In article <33vulq$8im@s-cwis.unomaha.edu>, hwolfe@corona (Herb Wolfe) writes:
|> Dale A Moore (damoore@pafosu1) wrote:
|> : Hi All,
|> :  I've been trying to get this stupid program to run forever
|> : and each time I get an error I've been deleteing lines.  So, now
|> : I'm to the point of only having 3 executable lines.  Can someone
|> : help??????

Yes -- see below.  However, this isn't the appropriate place to post with these
sorts of questions.  comp.std.c++ is for discussion of standardization issues
in C++.  The right place to post, if post you must, is comp.lang.c++.

|> maybe. this isn't exactly the place for this but i'll try anyways.
|> why keep deleting lines, though? why not comment them out?
|>
|> : void main(void)   {
|> :  char far *base_address = MK_FP(0xA000:0000);
|>
|> should this be an assignment? if so, you need another =

It should be an assignment, but the result of MK_FP is almost certainly a
void *, so you need a cast to assign it to char far *.

|> :  printf("The contents of this location are: %d\n",*base_address);
|> :  getch();
|> : }
|>
|> : The compiler then very rudely says "Cannot convert 'void *' to
|> :  'char *'.
|> : What!!!???  If it wants to tell me something why doesn't it say it
|> : in English?  Obviously, I don't get paid for programming...just
|> : torturing myself with it.  Someone - Please help.
|>
|> looks like english to me. btw, what do you get paid for if not programming?

Looks like English to me too!  It looks like Dale needs to read a C/C++ book...

As for what he gets paid to do, didn't you read his message?  He clearly states
that he gets paid for torturing himself with it (programming, that is). :-)

|> herb

--
---------------------------------------------------------------------
 Ed Osinski                  |
 Computer Science Department | "Do I know you?
 New York University         |  And don't try to deny it!"
 E-mail:  osinski@cs.nyu.edu |                 Col. Flagg to Hawkeye
---------------------------------------------------------------------




Author: pstaite@zool.rchland.ibm.com (Philip Staite)
Date: 31 Aug 1994 03:25:19 GMT
Raw View
Try this:

#include<iostream.h>  // hey, this is c++ after all :-)
#inlcude<dos.h>  // home of MK_FP

int main() {
    char far* ba = (char far*) MK_FP( 0xa000, 0x000 );
    // note, MK_FP requires two arguments according to Borland C++
    // segment and offset (gag)
    // returns a void* so you need to explicitly cast to anything else

    cout << "contents: " << hex << (unsigned) *ba << endl;
    return 0; }

Reading video memory eh???
--

Phil Staite, (507) 253-2529
internet: pstaite@vnet.ibm.com  internal: pstaite@rchland