[ccan] Portability [was Mathematics Module]

Rusty Russell rusty at rustcorp.com.au
Fri Jan 30 11:57:47 EST 2009


On Thursday 29 January 2009 23:25:53 Tim Post wrote:
> On Thu, 2009-01-29 at 12:19 +1030, Rusty Russell wrote:
> 
> > > Most people will be using a modern and fully functional C library.
> > 
> > I hope so, but I don't want to rule out catering to others.  SAMBA have 
> > a fairly complete set of replacements IIRC, but so far I've been happy to
> > assume ISO C (but if modules have lesser requirements that's fine too).
> 
> Alright, so POSIX creature comforts, advisories and IPC (signal) should
> be conditional upon config.h? IOW :
> 
> #ifdef POSIX
>    posix_fadvise(fileno(fp), 0, 0, POSIX_FADV_NOREUSE);
> #endif

Well, here are my thoughts to date:

1) Don't go looking for portability problems: wait for reports then solve
   them.  Otherwise you end up with untested ifdefs and messy code.

2) Sometimes the answer will be YA ccan module, sometimes it will be to
   indicate a requirement for the module to be used at all (eg. HAVE_X11
   tests in an x11 drawing library would be silly).

3) config.h style is HAVE_FEATURE, and test should be #if HAVE_FEATURE, not
   #ifdef.  This is deliberate: a new HAVE_ arrives and you get a warning
   if your config doesn't cover it (via. -Wundef).

Cheers!
Rusty.



More information about the ccan mailing list