bug-autoconf
[Top][All Lists]
Advanced

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

RE: Intrinsic functions fails AC_CHECK_FUNCS test


From: Jerker Bäck
Subject: RE: Intrinsic functions fails AC_CHECK_FUNCS test
Date: Mon, 27 Aug 2007 15:23:56 +0200

Hello Ralf,

> Is it portable to all MSVC versions, on w32, w64, on all MS Windows
> versions?  Is there a difference between MSVC on Interix and, say,
> "native" as run from MSYS, and if yes, is it portable to both, too?
Good point, I just assumed they would work since the pragmas are rather
common. First: The compiler behaves the same regardless of calling
environment (Visual Studio, Interix, Cygwin, Powershell, eclipse, DDK build
etc). However, there could be differences between compiler versions. So I
digged a bit and tested what I could get my hands on:

Compiler versions tested:
------------------------------------------
15.00.20404         x64   Visual Studio orcas beta
14.00.50727.762     x64   Visual Studio 2005 SP1
12.00.8804                Visual Studio 6.0 SP6
11.00.7022                Visual Studio 5.0
10.00.5270                Visual Studio 4.0
8.00c                     Visual C++ 1.52c (for 16bit)

Intel(R) C++ Compiler x64 - 20070426 ID: W_CC_P_10.0.025

Notes for 16bit (MSDOS)
Visual C++ 1.52c is the last compiler for MSDOS, released 1993. It's a 32bit
cross compiler for 16bit and is still used, delivered with Windows DDK (and
thus for "free").

The test routine
------------------------------------------
#ifdef __cplusplus
extern "C"
#endif
#define FUNC memcpy
#if defined (_MSC_VER)
#pragma warning(disable : 4163 4391 4392)
char FUNC ();
#pragma function( FUNC )
#else
char FUNC ();
#endif

int main()
{
    return FUNC();
}
------------------------------------------

Invoke command:
cl.exe -O2 -Oi test.c
cl.exe -O2 -Oi -Tp test.c   (for version < 1200)
icl.exe -O2 -Oi test.c

Results:
All tested MS compilers support #pragma function and succeed the test in
C++. In C, for compilers older then version 1200 (VS6), it seems that the
pragma have no effect and behaves as the autoconf original test (fails for
intrinsic functions). A solution for these compilers would be to run
autoconf with the C++ switch -Tp. The proposed addition does not introduce
any new warnings or errors, though. The Intel compilers defines _MSC_VER but
does not use #pragma function. Warnings but no error either way, even if
testing for intrinsic functions (odd!).

icl.exe output:
test.c(6): warning #1879: unimplemented pragma ignored
  #pragma function( FUNC )
          ^
test.c(13) (col. 9): warning #980: wrong number of actual
                arguments to intrinsic function "memcpy"

Comment:
Better leave the Intel compiler out of the condionalis, saves us the #1879
warning. It seems to manage the test anyway even with intrinsic functions.

Proposed addition c.m4(266)
-----------------------------------
#ifdef __cplusplus
extern "C"
#endif
+ #if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
+ #pragma warning(disable : 4163 4391 4392)
+ char $1 ();
+ #pragma function( $1 )
+ #else
char $1 ();
+ #endif
-----------------------------------

> Note that many users use older MSVC versions, e.g., because they also
> use older w32 versions.
No problem, see the test.

> Note that there is also the chance that completely unrelated compilers
> warn or even error out on about the above, even if they do not define
> _MSC_VER.  The few I've tried so far on GNU/Linux don't.
?? Compilers without support for #if, #else etc you mean, or? AFAIK, only
the MS and Intel compilers define _MSC_VER.

> Well, if we need to add code like above for different compilers,
> different versions, different compile options, on different systems,
> then this kind of approach will quickly grow unmaintainable.  However,
> if one snippet works for all w32/MSVC, and causes no other regressions,
> chances may be a bit better.
And add even more garbage to the config.log - yes I agree. A better solution
would be to have a compiler/system specific editable filter before the test.
Use the AN_* set of macros?


Cheers
Jerker






reply via email to

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