www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/07/23/09:40:00

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: malloc question.
Date: 23 Jul 2003 13:08:55 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 30
Message-ID: <bfm1d7$db6$1@nets3.rz.RWTH-Aachen.DE>
References: <84e4e2a9 DOT 0307230454 DOT 730046e5 AT posting DOT google DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1058965735 13670 137.226.32.75 (23 Jul 2003 13:08:55 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 23 Jul 2003 13:08:55 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Joel <jbs30000 AT aol DOT com> wrote:
> From here
> http://www.delorie.com/djgpp/doc/ug/graphics/vbe20.html
> I used code to get protected mode function offsets.  And instead of
> using vesa_pm_info I just called it VESA_PM.

Please re-think that decision.  By ancient tradition in both C and
C++, NAMES_IN_ALL_CAPS are reserved for #define'd macros and possibly
enum labels.  You'll mislead anyone else who may get to read your code
later.

> I got the error:
> svga/VBESetup.cpp(12) Error: invalid conversion from `void*' to `
>    Vesa_Protected_Mode_Info*'

That's a C++-specific thing, whereas the sample you looked at probably
was meant to be C code.  Unlike C, C++ doesn't let you silently cast
points from and to void *.

> But of course that doesn't necessarily mean that I'm doing this right,
> so I'd like to know, is that correct, or else how am I supposed to fix
> the problem?

C++ purists may insist on using one of the more explicitly meaningful
types of cast, or tell you to use "new" instead of malloc(), but the
fix you found is essentially correct.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019