Mail Archives: djgpp/1997/10/04/11:36:11
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 -