Extern functions inside library

Discussion in 'C Programming' started by karthy, May 16, 2006.

  1. karthy

    karthy Guest

    Hi,
    i have a C library with 3 files :
    file1.c, file2.c, file3.c
    The function, ext_func() that is needed by both file1.c and file2.c is
    in file3.c
    I have made that function as extern.
    Accidentally an application in which this library is integrated also
    has a function by name ext_func(). When my library calls ext_func()
    from within, the control goes to the ext_func() defined in the
    application and not to the one defined in the library.
    Can i solve this problem without changing the function name in the
    library and that in the application?
    i donot want to expose the function, ext_func() outside my library.
     
    karthy, May 16, 2006
    #1
    1. Advertising

  2. karthy

    Ico Guest

    karthy <> wrote:
    > Hi,
    > i have a C library with 3 files :
    > file1.c, file2.c, file3.c
    > The function, ext_func() that is needed by both file1.c and file2.c is
    > in file3.c
    > I have made that function as extern.
    > Accidentally an application in which this library is integrated also
    > has a function by name ext_func(). When my library calls ext_func()
    > from within, the control goes to the ext_func() defined in the
    > application and not to the one defined in the library.
    > Can i solve this problem without changing the function name in the
    > library and that in the application?
    > i donot want to expose the function, ext_func() outside my library.


    There is no portable way of doing this with the current files you are
    using now. A workaround wold be to Make the function static in the same
    file where it is called; this way it will not be visible beyond file
    scope, and it's symbol is not exported to other parts of the program.

    --
    :wq
    ^X^Cy^K^X^C^C^C^C
     
    Ico, May 16, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sergei
    Replies:
    4
    Views:
    5,272
    Denis Remezov
    May 15, 2004
  2. Thomas Matthews
    Replies:
    5
    Views:
    2,485
    tom_usenet
    Aug 2, 2004
  3. Replies:
    1
    Views:
    639
    David Lindauer
    Sep 30, 2004
  4. G Patel

    "extern" inside a block

    G Patel, Feb 23, 2005, in forum: C Programming
    Replies:
    12
    Views:
    585
    CBFalconer
    Feb 24, 2005
  5. Andre
    Replies:
    5
    Views:
    550
    Keith Thompson
    Jul 17, 2012
Loading...

Share This Page