Re: Circlemud design issues

From: George (greerga@CIRCLEMUD.ORG)
Date: 04/20/98


On Mon, 20 Apr 1998, James Turner wrote:

>> The very bad thing about inlined functions is that you have to put them in
>> header files (or a C file, but that's not the usual place).  Then any
>> change to that function causes large recompilation.  Then if you have a
>> compiler that doesn't support inlining, you lose.
>
>Not in C (at least, not under GCC).  Functions should _never_ be
>declared in a C header file.  They don't belong there.  Using gcc, you
>don't need to declare functions in headers or whatnot.  You can simply
>declare the function, adding the identifier 'inline' before the return
>type.  That's all.

But then the compiler cannot inline the function.  It needs to have
encountered the code for the function before it can inline it.  Unless GCC
2.8.1 has drastically changed this, you'll end up with inline and
non-inline versions.

>> >externs.h.  You and George are right that this does significantly
>> >increase the compile size; however, it simplifies the coding.
>>
>> Huh? If you're including a header for declarations you probably also need
>> some prototypes from it as well.  If logically organized that is.
>
>I don't understand quite what you're arguing here.  Breaking
>declarations up into structures/types, prototypes, and external
>declarations makes sense, and is a logical design.  What part of it do
>you feel isn't?

If you separate structures, prototypes, and externs into different headers
you've just eliminated a major reason to have separate headers, minimal
compilation.  That's why we have the 'make' tool and don't simply recompile
everything.

>The following file compiled 36 times in 28 seconds on my system.
[...]
>#if'ing the includes out, the same compile, 36 times, takes 7 seconds.
[...]
>So the headers add about 21 seconds to the compile.
[...]
>The time compiling headers is miniscule, and really shouldn't be a factor
>in deciding how to break the headers up.

(time gcc -c file.c, repeated three times, and averaged.)

act.wizard.c (72,355)- 6 seconds
act.wizard.c headers - .5 seconds
8% of the time.

mobact.c (5,743) - .9 seconds
mobact.c headers - .5 seconds
55% of the time.

It all depends on the file.

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST