autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AC_LINK_IFELSE with two (or more) sources?


From: Eric Lemings
Subject: AC_LINK_IFELSE with two (or more) sources?
Date: Fri, 2 May 2008 16:30:51 -0600

Greetings,

Currently, the AC_LINK_IFELSE macro only accepts one source file.  For
some C++ linkage tests, two (or more) sources need to be linked
together.  For example, consider the following two C++ source files:

file conftest1.cpp:
        // also defined in conftest2.cpp
        intline int foo ()
        {
            // multiple instances of 'i' must be collapsed
            static int i = 0;
            return i++;
        }

        #if defined _WIN32 && defined _DLL
        __declspec (dllexport)
        #endif // defined _WIN32 && defined _DLL
        int bar ()
        {
            return foo ();
        }

file conftest2.cpp:
        // also defined in conftest1.cpp
        intline int foo ()
        {
            // multiple instances of 'i' must be collapsed
            static int i = 0;
            return i++;
        }
        
        // bar() returns foo()
        extern int bar ();
        
        int main ()
        {
            // C++ compilers that correctly collapse static locals will
            // behave as commented below (others will return 0 from
bar())
        
            int i = foo ();  // returns 0
            int j = bar ();  // should return 1
        
            return !(i != j);
        }

My question is, are there any Autoconf-compatible macros in circulation
that support something like this?  If not, how would a welll-written
Autoconf macro supporting such behavior be implemented in general?  (I
suspect a customized AC_LANG(C++) macro to define an alternate ac_link
variable might do the trick.)

Thanks,
Eric.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]