473,414 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Extern functions inside library

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.

May 16 '06 #1
1 1502
Ico
karthy <n.******@gmail.com> 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
May 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sergei | last post by:
I ran into this problem. I needed to create an entry for access to a library of functions that are "extern C", and I just can't find the right syntax, if it exists at all ( I am using MSVC...
1
by: terrencel | last post by:
I was told to look at some old C code that was ported to C++. One of the file is like: ========================================= CPPClass* someCPPVar = NULL; extern "C" {
10
by: Mark A. Gibbs | last post by:
I have a question about mixing C and C++. In a C++ translation unit, I want to define a function with internal linkage and C calling convention. Here's a sample of what I want to do: //...
6
by: atv | last post by:
Alright, i have some questions concerning include files en global variables.I hope someone is willing to answer these. 1).Why is it that if i define a global variable in a file, say main.c, and...
5
by: siliconwafer | last post by:
Hi all, I wanted to know that is use of extern keyword mandatory in case of global variables and functions used in other source files? i.e consider a following piece of code from MSDN explaining...
7
by: pauldepstein | last post by:
#include <iostream> using namespace std; int main() { extern "C" int f(int, int);
2
by: Bharath | last post by:
Hi All, I am a newbie to C++ and I'm trying to figure this out. Can you please help? We have 3rd party library that's written in c++. We don't have the source for it. ldd on that shared...
4
by: mimi | last post by:
The programmer indicates to the compiler that a function is written in a different programming language using a linkage directives.It is intuitive that extern "SomeLanguage" is used to declare...
5
by: Medvedev | last post by:
What's that preprocessor do #ifdef __cplusplus extern "C" { #endif .. .. .. #ifdef __cplusplus } #endif
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.