473,395 Members | 1,681 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,395 software developers and data experts.

How to know linked Files

Hi,

I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?

Thanks,
Rayuthar
Jun 27 '08 #1
10 1123
On Apr 23, 8:23*am, rayut...@gmail.com wrote:
Hi,

I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?

Thanks,
Rayuthar
You could may be enable trace on when you compile to see if the files
are compiled and linked.

Suresh M. Shenoy
Jun 27 '08 #2
ra******@gmail.com wrote:
Hi,

I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?
What difference would it make? Since A uses nothing that
is defined in B (if it did, you could not make an executable
from A alone), anything B contributes is inaccessible.

What is the larger problem you are trying to solve?

--
Eric Sosman
es*****@ieee-dot-org.invalid
Jun 27 '08 #3
On Apr 23, 5:50 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
rayut...@gmail.com wrote:
Hi,
I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?

What difference would it make? Since A uses nothing that
is defined in B (if it did, you could not make an executable
from A alone), anything B contributes is inaccessible.

What is the larger problem you are trying to solve?

--
Eric Sosman
esos...@ieee-dot-org.invalid
I want to check if A is linked with B or not, if linked i will use the
function from B else i will go for any other way.
Jun 27 '08 #4
On Apr 23, 5:50 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
rayut...@gmail.com wrote:
Hi,
I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?

What difference would it make? Since A uses nothing that
is defined in B (if it did, you could not make an executable
from A alone), anything B contributes is inaccessible.

What is the larger problem you are trying to solve?

--
Eric Sosman
esos...@ieee-dot-org.invalid
sorry if posted twice!

If B is linked, then i will use the function from B else i will go for
my own function.

Thanks,
Jun 27 '08 #5
ra******@gmail.com wrote:
On Apr 23, 5:50 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
>rayut...@gmail.com wrote:
>>Hi,
I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?
What difference would it make? Since A uses nothing that
is defined in B (if it did, you could not make an executable
from A alone), anything B contributes is inaccessible.

What is the larger problem you are trying to solve?

I want to check if A is linked with B or not, if linked i will use the
function from B else i will go for any other way.
The C language cannot do this[*], because "stand-alone A"
cannot refer to anything in B. Therefore if A itself does
not change when B is added, the "partnered A" still has no
reference to anything in B and cannot call anything in B.
Even if something in A manages to discover that B is present,
it still has no way to call functions that are in B.

"C with extensions" is able to do this kind of thing on
some systems, using system-dependent mechanisms that are not
part of the C language itself. Try asking your question on
newsgroups that discuss the systems you're interested in.
[*] Perhaps an interpreted C implementation could do it,
but since the O.P. talks about "linking" files I think we
can ignore the possibility.

--
Er*********@sun.com

Jun 27 '08 #6
On Apr 23, 3:01 pm, rayut...@gmail.com wrote:
If B is linked, then i will use the function from B else i will go for
my own function.
I was in the same situation a while back, and I haven't found anything
better than checking whether a symbol from B is present or not in the
program using dlopen/dlsym with a NULL filename.

It's not standard C (it's POSIX), and it seems to be a very heavy tool
for that purpose, so I would be glad to hear of a better solution (if
such a solution exists).
Jun 27 '08 #7
ra******@gmail.com wrote:
>
On Apr 23, 5:50 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrote:
rayut...@gmail.com wrote:
Hi,
I have two files A.c and B.c , i can make executable with A.c alone or
addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?
What difference would it make? Since A uses nothing that
is defined in B (if it did, you could not make an executable
from A alone), anything B contributes is inaccessible.

What is the larger problem you are trying to solve?

I want to check if A is linked with B or not, if linked i will use the
function from B else i will go for any other way.
Basically, you want to determine, at runtime, if a function of a
given name existed at link time?

As others have pointed out, you can't do this in anything resembling
portable code. There may be a system-specific way of doing this,
but you would have to check in a system-specific group for such info.

What I would recommend is a slight variation on your request. Rather
than linking with B or nothing, link with B or "alternate B", and
have both include a _pointer_ to the function, with "alternate B"
having a NULL pointer.[*] Have your A code check for a non-NULL
pointer, and call the function indirectly. As an alternative to
this method of explicitly linking with "alternate B", you may be
able to supply a library which is always linked with the code. If
you link with B, the pointer symbol will be resolved, and your
"alternate B" module from the library shouldn't be included. If
you link without B, your library module with the NULL pointer
should be linked it.

[*] Technically, I don't think a code pointer can be NULL, as a
code pointer may not be represented the same as a data pointer.
(Though I have to admit that I use such a construct in my code.)
You could always make your own definition for a null code
pointer, such as:

typedef int (*IntFunc)();
#define NULL_INT_FUNC ((IntFunc)0)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Jun 27 '08 #8
Kenneth Brody <ke******@spamcop.netwrites:
<snip>
[*] Technically, I don't think a code pointer can be NULL, as a
code pointer may not be represented the same as a data pointer.
(Though I have to admit that I use such a construct in my code.)
You are in the clear. Function pointers can be assigned NULL and can
be compared against NULL (specifically against any null pointer
constant).

--
Ben.
Jun 27 '08 #9
Hi List

Can't that work like:

#ifdef whatever_in_b.c

/*call here the function/variable in b.c, set the return value to
local scope variable*/

#elif

/*use a standard value*/

#endif

Still can't see the point in do that (since it's very easy to know, on
compile/link time, if b.c is there or not), but that can work as far
as I can see, anyway. Some headers can be necessary to work with that
"solution".

Regards
Rafael
Jun 27 '08 #10
>I have two files A.c and B.c , i can make executable with A.c alone or
>addition to B.c. If i make executable with two files , how can i know
B.c is linked with A.c?
On some implementations, if A.c needs something in B.c and it's not
linked with B.c or something else that supplies it, the resulting
executable will get an error on the link and won't run (or possibly
the linker won't even create an executable).
Jun 27 '08 #11

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

Similar topics

0
by: Chris Powell | last post by:
I am using Excel/Access 2000 and have two large Excel files (25,000 rows each) that I wish to create linked tables in Access rather than importing into Access. The two source Excel files change...
2
by: Internet Arrow Limited | last post by:
Hi, I have a requirement to write an access application that must run under access97 and access2K. Some users will use Acess2K to access data that will also be accessed by Access97 users. The...
3
by: Michael Plant | last post by:
Hello one and all. I have a stored table in my database and the form I'm using is based on a query that draws data from my stored table and a linked table. The linked table is a *.txt file. ...
7
by: bill.brennum | last post by:
Hi, Have a number of Access Databases that I inherited and want to zip a few of them. My concern is that other active Microsoft Applications may be linking to the database or its tables. Is...
0
by: ORC | last post by:
Applies to C#, Visual Studio 2003 version 7.1.3088. I have a project where I have several linked files included. One problem is that when I make changes in one of the linked file I will have to...
2
by: sunset85 | last post by:
Hi. I'm trying to scan linked source directory using "cscope" In normal case (without linked source directory), "cscope -R " works vety well. But when linked source directory included,...
6
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would...
8
by: dmp | last post by:
What are Linked list? Please somebody show some ready made programs of linked list
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.