Mats Kindahl wrote:
>
> Monty Taylor wrote:
>> 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.
>
> Good, but where should project-wide generic definitions be put (talking
> typedef's here)?
I'm not sure which of these we actually need? Do you have an example?
>> 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])))
>
> I truly think that these macros does not add anything except mudding the
> waters.
> Those pieces of code is simple enough to type that there is no need for a
> macro
> (and that cast is wrong: size_t may be bigger than uint32_t, resulting in
> truncation).
Agree.
>> typedef my_off_t off_t;
>> typedef off_t os_off_t;
>
> I don't see the point of these.
Agree.
>> 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.
>
> Isn't that something config.h:is?
Well, config.h defines the TIME_WITH_SYS_TIME and HAVE_SYS_TIME_H, but
doesn't
actually do the includes... but maybe there just aren't enough places where
this happens for it to matter.
> Just my few cents,
> Mats Kindahl
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp