Mail Archives: djgpp/1997/10/04/11:36:11

Sender: crough45 AT amc DOT de
Message-Id: <>
Date: Sat, 4 Oct 1997 16:33:24 +0100
From: Chris Croughton <crough45 AT amc DOT de>
Mime-Version: 1.0
To: djgpp AT delorie DOT com
Cc: kwall AT utw DOT com
Subject: Re: Bad debugging code for class functions in header

Kurt Wall wrote:

> Tsk, tsk.  Putting code in a header file...

You obviously don't program in C++.  There is a very valid
reason for putting the code in the class definition:

   it's the /only/ way to get inline functions (when the
   compiler does inline them - for debugging I need to
   run with optimisations off).

And since in C++ you are supposed to use inline functions
instead of macros, there's nowhere else to put them (for
that matter what is a macro except code in a header file?).

Now if it were a proper high-level language, where you
could export code from a module so the compiler could
just insert it, and you wouldn't have to define everything
twice, that would be different.  In a real HLL I could have
module which said something like:

export class foo
  void fred()

and the compiler would generate an internal-format file 
which contained all the declarations and definitions 
required for another module to import and inline the
function calls.

But it isn't, it's C++, and it doesn't work (as far as 
debugging is concerned) on the DJGPP port as far as I 
can see.

(Actually, I don't know if even Ada and Modula do this
properly either.  It depends on whether the compiler 
and linker can handle it, most seem to not generate 
inline code for such cases...)

Chris C

- Raw text -

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