[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ltdl.c and 1.4.1 (type conflicts)
From: |
Gary V. Vaughan |
Subject: |
Re: ltdl.c and 1.4.1 (type conflicts) |
Date: |
Mon, 10 Sep 2001 20:33:07 +0100 |
User-agent: |
Mutt/1.3.21i |
On Sat, Sep 08, 2001 at 01:49:35AM -0700, Bruce Korb wrote:
> Robert Collins wrote:
> >
> > On Sat, 2001-09-08 at 13:31, Gary V. Vaughan wrote:
> > > On Fri, Sep 07, 2001 at 02:45:11PM -0500, Tim Mooney wrote:
> > > Phew! Thanks for that info.
> > >
> > > I'm open to suggestions for a cleaner way to implement this, but I
> > > think that it is an unavoidable weakness in C that forces one to (ab)use
> > > void* in cases such as this.
> >
> > I haven't checked the code in question, but if what youa re doing is
> > returning a pointer to a function froma function, then typdef'ing a
> > function pointer type and returning that should be a clean solution.
> >
> > ie if the function type being passed around is
> > int func(char *, int)
> >
> > typedef int functype(char *, int);
> >
> > functype *
> > functionthatreturnspointertofunction()
> > {
> > ...
> > }
>
> That's my preferred solution, too. Unfortunately, libtool is _still_
> trying to be K&R compatible, and ancient K&R won't let you typedef
> procedures.
I didn't know that... pfff. :-P
Anyway, would that it were so easy. foreach_dirinpath is a general
helper function used in all sorts of contexts throughout ltdl.c:
typedef int foreach_callback_func LT_PARAMS((char *filename, lt_ptr data1,
lt_ptr data2));
static int
foreach_dirinpath (search_path, base_name, func, data1, data2)
const char *search_path;
const char *base_name;
foreach_callback_func *func;
lt_ptr data1;
lt_ptr data2;
{
...
}
This is an API call, implemented over foreach_dirinpath:
int
lt_dlforeachfile (search_path, func, data)
const char *search_path;
int (*func) LT_PARAMS ((const char *filename, lt_ptr data));
lt_ptr data;
{
...
if (search_path)
{
/* If a specific path was passed, search only the directories
listed in it. */
is_done = foreach_dirinpath (search_path, 0,
foreachfile_callback, func, data);
}
...
}
This function has to match the foreach_callback_func footprint, so
that it can be passed to foreach_dirinpath, but it also needs to accept
a function pointer itself to work with lt_dlforeachfile:
static int
foreachfile_callback (dirname, data1, data2)
char *dirname;
lt_ptr data1;
lt_ptr data2;
{
int (*func) LT_PARAMS((const char *filename, lt_ptr data))
= (int (*) LT_PARAMS((const char *filename, lt_ptr data))) data1;
^^^^^^ Here is one of the casts xlc dislikes ^^^^^
...
{
char *filename = 0;
while ((filename = argz_next (argz, argz_len, filename)))
if ((is_done = (*func) (filename, data2)))
break;
} }
...
}
Suggestions?
Cheers,
Gary.
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
- ltdl.c and 1.4.1 (type conflicts), libtool, 2001/09/05
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/06
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/06
- Re: ltdl.c and 1.4.1 (type conflicts), libtool, 2001/09/06
- Re: ltdl.c and 1.4.1 (type conflicts), Tim Mooney, 2001/09/07
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/07
- Re: ltdl.c and 1.4.1 (type conflicts), Robert Collins, 2001/09/08
- Re: ltdl.c and 1.4.1 (type conflicts), Bruce Korb, 2001/09/08
- Re: ltdl.c and 1.4.1 (type conflicts),
Gary V. Vaughan <=
- Re: ltdl.c and 1.4.1 (type conflicts), Bruce Korb, 2001/09/10
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/10
- Re: ltdl.c and 1.4.1 (type conflicts), Tim Mooney, 2001/09/11
- Re: ltdl.c and 1.4.1 (type conflicts), Bruce Korb, 2001/09/12
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/13
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/13
- Re: ltdl.c and 1.4.1 (type conflicts), Tim Mooney, 2001/09/13
- Re: ltdl.c and 1.4.1 (type conflicts), Tim Mooney, 2001/09/13
- Re: ltdl.c and 1.4.1 (type conflicts), Gary V. Vaughan, 2001/09/13
- Re: ltdl.c and 1.4.1 (type conflicts), Tim Mooney, 2001/09/13