Michael Widenius wrote:
>>>>>> "Tor" == Tor Didriksen <Tor.Didriksen@stripped> writes:
>>> class Table_ident; /* Need to be before include of sql_yacc.h */
>>> class Item_num;
>>> class String;
>>> class Key_part_spec;
>>> struct TABLE_LIST;
>>> typedef struct st_udf_func udf_func;
>>> typedef struct st_lex_user LEX_USER;
>>> #include "sql_list.h" /* Pull in List<> */
>>> #include "set_var.h" /* Pull in sys_var_with_base */
>>> #include "sql_yacc.h" /* Pull in symbol definitions */
>>> For each line, I had to do a symbol search to find the definition of it
>>> and see
>>> how and where it was defined. Most other files have similar
> Tor> wow!
> Tor> Each header file should have been self-contained of course, there should
> Tor> be no need for forward declarations before #include
> There is no 'of course' in that.
> If you try to do every include file self-contained, you need a LOT of
> more includes 'just in case' and dependents that just creates more
> code, more parsing without giving you anything.
> MySQL was design with the idea that you in most cases only have to
> include one (but in practice a few) include files in each source file.
> The benefit of this is:
> - Easier to decide what to include
> - Faster compile time for all compilers
> - MUCH faster compile time for compilers that support precompiled
> - Easier to handle header files with conditionals as you are less
> likely to include these before all the required definitions are
I think a coding policy that optimizes for minimization of includes and compile
speed is not focusing on the right things.
Also, for the current code, deciding what to include is not very easy since
header files are dependent on other header files being included before they are
Senior Software Engineer
Database Technology Group