George <greerga@CIRCLEMUD.ORG> writes: > 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. Yes, it can. As you said in another post, gcc can sometimes automagically inline with the -O3 or -finline-functions. It doesn't need functions declared in headers for this. The compiler generates two pieces of code. One is the normal version (one which you can take the address of, ie, for use as a function pointer), and the inlined version. It will call the inlined version when possible. If it is declared static and inline, no normal version will be generated (if certain other restrictions are met). You are thinking of declaring a function as both extern and inline. Check the gcc info pages for details on this (under C extensions). > >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. Make isn't designed to simply handle header changes -- it is more used to handle .c file changes. It does handle depends quite well; however, having to include 8 different files can become a royal pain, as well as lead to ambiguities (particularly in references to structures declared across these header files). > (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. You're proving my point :) It's the c file, not the header, which has the larger impact on compilation time. -- James Turner turnerjh@xtn.net http://www.vuse.vanderbilt.edu/~turnerj1/ +------------------------------------------------------------+ | 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