Hey guys,

This may go without saying, but I wanted to lay out a potential goal for
the headers and how we do some of the config things.

1) global.h goes away. It's a crutch.

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.

4) All files should include the things they need rather than assuming
that those includes will have been included by someone else earlier.
(config.h gets an exception here)

3 shouldn't be a problem, because all of the "#ifdef HAVE_STDINT_H"
stuff should be included first by the C file anyway because of 2.

The stuff that's in global.h mostly falls into three categories:

- Setting compiler capabilities:

  #define _POSIX_PTHREAD_SEMANTICS

  This should all be done by autoconf, since autoconf knows all sorts of
stuff about the env, and is where we would add tests for capabilities
anyway.

- 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.

- 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.

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

I'd hate to make people do this everywhere they need time.h or sys/time.h.

-- 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

Which could be useful if we wanted to start using some things from
C++0x, like cstdint. For gcc, it's:

#include <tr1/cstdint>
but Boost also provides is:
#include <boost/cstdint>

I think this is a good autoconf solved thing, but I wanted to make sure
people were ok with it.


Any thoughts or disagreements here? Trond has already started making
more things include config.h to make the Solaris build work better.

Monty

_______________________________________________
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