Email List: Xaustin-group-lX
[All Lists]

Re: Return type of dlsym

To: Wojtek Lerch <yyyyyy@xxxxxxx>
Subject: Re: Return type of dlsym
From: "Clive D.W. Feather" <yyyyy@xxxxxxxxx>
Date: Wed, 17 Apr 2002 09:09:34 +0100
Cc: Marc Aurele La France <yyy@xxxxxxxxxxx>, Matt Seitz <yyyyyy@xxxxxxxxx>, yyyyyyyyyyyyyy@xxxxxxxxxxxxx
References: <Pine.A41.4.33.0204160958530.33140-100000@gpu2.srv.ualberta.ca> <200204162110.RAA19174@node1.ott.qnx.com>
Wojtek Lerch said:
> Splitting dlsym() into two functions would be a more elegant way, but it
> might break some existing code more seriously.  Personally, I think that
> doing both is the best solution.

It's just struck me that the split has another benefit: if the symbol is in
the library, but not with the type expected by the programmer, having
separate functions allows the problem to be diagnosed. In other words, we
have:

                           data pointer         function pointer
    void * dlsym ()        returns pointer      returns NULL or a cookie [*]
    void * dlsym_d ()      returns pointer      returns NULL
    fptr_t dlsym_f ()      returns NULL         returns pointer

[*] On some implementations, casting this cookie to fptr_t will produce the
same value that dlsym_f would have done. On other implementations it will
produce a value of no use whatsoever.

-- 
Clive D.W. Feather  | Work:  <yyyyy@xxxxxxxxx>   | Tel:  +44 20 8371 1138
Internet Expert     | Home:  <yyyyy@xxxxxxxxxx>  | Fax:  +44 870 051 9937
Demon Internet      | WWW: http://www.davros.org | Mobile: +44 7973 377646
Thus plc            |                            | NOTE: fax number change

<Prev in Thread] Current Thread [Next in Thread>