AC_LINK_IFELSE with two (or more) sources?

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

 



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.


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf


[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux