[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to implement replacement functions (scandir, alphasort) in libra

From: Nick Bowler
Subject: Re: How to implement replacement functions (scandir, alphasort) in library?
Date: Thu, 5 May 2011 17:39:26 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi David,

On 2011-05-05 20:30 +0000, David Bruce wrote:
> Sorry if this question is too general.  I maintain two cross-platform
> programs (tuxmath and tuxtype), which are being refactored to use a
> common library, t4k_common. Both programs use autoconf to test for the
> presence of scandir and alphasort,

First, note that both of these functions are provided by gnulib.
Thus you might want to consider using gnulib for these if you are
not already.

> and conditionally compile replacements as needed.  I'd like to move
> this "replacement function" code into the common library.  From the
> standpoint of the game program itself, e.g. tuxmath, it would be
> simplest for the library's header file to have the prototypes of the
> replacement functions be conditionally present, e.g.:

What I suggest in this case is to define completely new functions in
your library, say t4k_scandir and t4k_alphasort, that are always
present.  On platforms where scandir/alphasort are provided, these
functions would be simple wrappers.  Otherwise, the implementation
will be included in the library.

This allows your library to maintain a consistent interface regardless
of how it's configured.  Ideally, your library header files would then
be independent of the configuration.

Hope that helps,
Nick Bowler, Elliptic Technologies (

reply via email to

[Prev in Thread] Current Thread [Next in Thread]