Different Functions of Same Name in Different Libs

Different Functions of Same Name in Different Libs

Post by Scott B. Drummond » Fri, 23 Jul 1999 04:00:00



I'm trying to architect a program to eliminate unresolved symbols.  I'm
doing so in the following manner:

//  Header file
class Interface {
public:
    static void myFunc();

Quote:};

//  End Header file

//  Library 1
Interface::myFunc() {assert (0);}

if (a) {   //  'a' would *ONLY* be set in a program that also linked library
2.
    Interface::myFunc();

Quote:}

else {
    otherFunc();
Quote:}

//  End Library 1

//  Library 2
Interface::myFunc() { /* real code */ }
//  End Library 2

As you can see, myFunc should *NEVER* be called from a program that just
uses library 1.  That is correct operation.

However, in some programs, I want to set 'a' and call the myFunc() in
library 2.  Obviously I can't remove the myFunc() dummy declaration from
library 1 or I will get an unresolved symbol problem when linking programs
that only use library 1.

But, I'm afraid that the linker may arbitrarily choose one of the myFunc()'s
and sometimes choose the wrong one.  Is every linker's choice deterministic?
I mean, can I always link library 2 before library 1 and guarantee that the
second myFunc() is chosen when it is linked?  Is there some other linker or
compiler switch I can give to be sure that the library 2 implementation is
used when it is linked?  Or, is making a program like the above guaranteed
to cause cross-platform havoc?

Thanks in advance,
Scott

 
 
 

1. different file names under different shells

hi

    I have two questions. The first one is whether it is possible for a
file
to have different names under bash and csh. In my department's system, I
came across a strange thing that a folder is called "\r" under bash and
"?'
under csh. It seemed that "?" is the right name. Under csh, I can "cd"
into
"?". But under bash, I can't "cd" into "\r".

    The second one is that in shell script "startx", there is a line
including a expression "/''*". I am wondering whether "\*" is enough.
What
is the use of two single quotes in the "\''*".

    Any help will be much appreciated.

Lei

2. Linux Machine as Unix Dial-in and Voice Answering Machine?

3. Using different IP Names for different Unix apps.

4. When I set up X my No.9

5. Is it possible for a file has different names under different shells

6. netstat

7. Resolving different domain names to different pages?

8. X free86 3.1.2 and S3vision 868 and A Samsung 17Glsi monitor

9. export a function with a different name?

10. How to setup named to let two names relate to different ports on thew same machine

11. UUCP name different than HOST name

12. different screen setup for different terminal?

13. Apache: different default locations for different users?