From: Maurice L. <mj...@ga...> - 2002-11-26 19:15:25
|
Alan W. Irwin writes: > (2) should be changed to > typedef lt_ptr (*PLDispatchInit)( PLDispatchTable *pdt ); > > Any C expert on the list know why *PLDispatchInit rather than > PLDispatchInit? I naively thought you would drop the asterisk because the > type was going from void * to lt_ptr, but as you all know, my C programming > skills are not the best especially when dealing with pointers and > complicated typedefs. The example of typedef on p. 147 of the little white > K&R book is analogous to this one, but I don't understand the point of > (*PFI) rather than (PFI) in that case as well. It looks to me you're going from a void (not void*) to lt_ptr, since the original typedef was: typedef void (*PLDispatchInit)( PLDispatchTable *pdt ); The new typedef: typedef lt_ptr (*func)( PLDispatchTable *pdt ); allows you to declare a function pointer in the following way: func dispatch_init; which means that: dispatch_init is a pointer to a function that passes a pointer to a PLDispatchTable and returns lt_ptr. It doesn't matter what "func" is called, in this case PLDispatchInit. One confusing point is that ANSI C allows you to drop the explicit dereference when making the actual function call, i.e. (*dispatch_init)(pdt); and dispatch_init(pdt); are the same. But since you have to keep the distinction straight in the declaration, the first form is probably better (IMO) as being more transparent. > One other issue I ran into was how to initialize libltdl and release its > memory when done. Same old problem (mentioned in the plcore.c comments) of > no clear PLplot library initialization . So I chose to do the initialize > whenever a stream was created and release whenever it was destroyed. This > is overcomplicated, and it would be better to initialize just once before > any streams are created and release after they are all destroyed, but there > is no clear way to tell when plinit is first called so I had to do it stream > by stream. Could it go in pllib_init()? I added this earlier this year to help solve this problem -- any routine the user might call first (if I didn't miss any) calls this first to do library initialization. > The AT effort is going much faster than I thought (because of the great > start by Rafael and because autotools is pretty easy to learn from scratch) > so the merge to HEAD *could* happen soon (i.e., maybe even sometime during > this week unless I run into unforseen problems.) So I suggest you should get > involved immediately if you want to evaluate the AT approach before the > merge! Will try, but am very very busy. I appreciate all your effort on this tho. > Alan -- Maurice LeBrun mj...@ga... Research Organization for Information Science and Technology of Japan (RIST) |