delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/09/01:07:58

From: lonniem AT cs DOT utexas DOT edu (Lonnie McCullough)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C++ question
Date: Mon, 09 Jun 1997 05:12:31 GMT
Message-ID: <339b8e5e.2584922@news.nol.net>
References: <01bc7396$c7dd77c0$ba4741c2 AT nop44597>
NNTP-Posting-Host: ip38-42.nol.net
Lines: 56
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On 8 Jun 1997 01:00:29 GMT, "Telepac" <suporte AT mail DOT telepac DOT pt> wrote:

>I´ve been seeing a lot of discusing about C++ versus C for games and that
>kind of stuff.
>I´ve been reading, trying to decide if C++ is good for games, but it seems
>that there isnt an answer....
>
>Could anyone tell if DJGGP makes good C++ code.
>
>I´m now learning C++, and i think its OK for games...
>I think that without notice, we are just using a kinda of structs.
>
>I think the idea of class's and objects are just for protecting data and
>code from beeing missuse, and a good compiler would compile pretty much
>like C code.
>
>Can anyone give me some light about it ?
>
>-- 
>Silent Dreamer
>silentdreamer AT mail DOT telepac DOT pt

DJGPP produces good C++ code (at least the stuff I have moved from C
to C++ has been just as fast in C++) and is more than suitable, in
fact I think it's great, for a game.  The idea of having a player
object based on a generic entity object (the heirarchy would be more
complex than this probably but just to give an idea) is great because
with one function (a virtual function) you can pretend that you are
taking life from a generic entity when in fact you are taking life
from your player.  It simplifies things incredibly to have to program
only in terms of a base class and the operations that apply to that
generic base class.  But never fear resorting to a little asm to speed
things up.  In C++ do it like this

/* INCLUDEFILE.H */

extern "C"
{
  void asm_routine (void);
  ...
}

/* ASM.S */
...
_asm_routine:
ret
...

if you don't do the extern "C" {} then the functions you declare will
be subject to C++ name mangling and it'll be hard to figure out what
label to use to define your function in ASM.S.  It just makes life
easier on you.


Lonnie McCullough
lonniem AT cs DOT utexas DOT edu

- Raw text -


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