On Fri, Oct 03, 2008 at 11:48:08AM -0700, Monty Taylor wrote:
> 1) global.h goes away. It's a crutch.

yay!

> 2) config.h should be included as the first thing be C files.
> 
> 3) config.h should _never_ under _any_  _circumstances_ be included by
> .h files.

We can even solve the "but I rely on config.h and if not included, bad
things happen" by a simple:

#ifndef HAVE_CONFIG_H
#error "Include config.h first, in source file."
#endif

which is a much nicer replacement for the #include.
>
> - creating our own mini-language out of cpp macros:
> 
>   #define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
>   #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
>   #define array_elements(A) ((uint32_t) (sizeof(A)/sizeof(A[0])))
>   typedef my_off_t off_t;
>   typedef off_t os_off_t;
> 
>   We can make a util.h somewhe and turn these in to inline functions
>   Since we're C++, we can make those inline functions template functions
>   to handle the typing. But these are all ugly.

Or just write clear and clean and obvious code instead of this garbage.

> - making sure we include "standard" things
> 
>   #ifdef HAVE_SYS_SOCKET_H
>   #include <sys/socket.h>
>   #endif
> 
>   Thing is, not everything needs sys/socket.h, and so honestly most
>   things shouldn't have to include it during their compile. And if we
>   follow (4) from above, we should be ok.

If in more than one source file, and it's a complex thing of "what to
include" (we get away from a bunch of those problems by not having
Windows support) then personally i don't mind a drizzle_socket.h or
something that sorts it out for us - preventing mistakes that break
non-linux (as it's always non-linux that's the problem).

> Outstanding questions:
> 
> -- What do we do about stuff like this?
> 
> #if TIME_WITH_SYS_TIME
> # include <sys/time.h>
> # include <time.h>
> #else
> # if HAVE_SYS_TIME_H
> #  include <sys/time.h>
> # else
> #  include <time.h>
> # endif

What about above suggestion? a drizzle_time.h which just has this snippet?

> -- Are we ok with defined includes?
> 
> Google does this in the protobuf source in config.h:
> 
> /* the location of <hash_map> */
> #define HASH_MAP_H <ext/hash_map>
> 
> And then in the source:
> 
> #include HASH_MAP_H

kinda ick... at least IMHO. But then again, I also think the lack of a
.h or .hpp on the end is an abomination.

-- 
Stewart Smith

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to