how to link to internal functions in a library

This is a discussion on how to link to internal functions in a library within the C Programming forums, part of the General Programming Boards category; I am using an open source library, there are quite a few interesting functions prototypes defined this way in a ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    48

    how to link to internal functions in a library

    I am using an open source library, there are quite a few interesting functions prototypes defined this way in a non-interface header file:

    #define somefunction _somefunction
    void somefunction(int a);

    I write my routine which calls somefunction(). After include the non-interface header, my routine can compile, but failed to link to the library. So I linked to the *.o files directly. It works, but the solution is ugly.

    So the questions is how to reuse the internal functions from a library. Any suggestion?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    You're not meant to use internal functions from some other library.

    If you really want to export the function from the library, then you need to remove this line
    #define somefunction _somefunction

    Which is OK, if you're never going to push any changes to that library, or make your own source code available for others.

    But if you do want to publish anything, you need another approach (or a good explanation for the library maintainers).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. changing internal representation of a struct library
    By fisheromen1031 in forum C Programming
    Replies: 4
    Last Post: 11-13-2009, 05:24 PM
  2. Replies: 1
    Last Post: 01-11-2007, 04:22 PM
  3. Replies: 19
    Last Post: 01-12-2006, 10:04 AM
  4. Dev C++ library to link
    By WDT in forum Networking/Device Communication
    Replies: 3
    Last Post: 03-20-2004, 10:20 AM
  5. local IP identification via C internal functions
    By andrew in forum C Programming
    Replies: 0
    Last Post: 12-19-2001, 05:46 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21