autoconf
[Top][All Lists]
Advanced

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

AC_FUNC_SETVBUF_REVERSED - shouldn't it be the other way around?


From: Jerker Bäck
Subject: AC_FUNC_SETVBUF_REVERSED - shouldn't it be the other way around?
Date: Mon, 27 Nov 2006 01:37:32 +0100

Hello all,
The AC_FUNC_SETVBUF_REVERSED macro seems to be fairly common and used in a
number of tools (ex GNU make).
The macro always fails to test the MS compiler resulting in the wrong
"#define SETVBUF_REVERSED 1", but succeed in testing gcc. In this case, both
compilers are using the same C-library (Interix BSD LIBC). Why is that?

The test expands like this:

// Interix BSD LIBC prototype
// extern int __cdecl setvbuf (FILE *, char *, int, size_t);

int main ()
{
    char buf;
    if (setvbuf (stdout, _IOLBF, &buf, 1) != 0)
        return 1;
    putchar ('\r');
    return 0; /* Non-reversed systems SEGV here.  */
}

$ gcc -c setvbuf_reversed.c
setvbuf_reversed.c: In function `int main()':
setvbuf_reversed.c:13: error: invalid conversion from `int' to `char*'
setvbuf_reversed.c:13: error: invalid conversion from `char*' to `int'

$ cc -c setvbuf_reversed.c
setvbuf_reversed.c(13) : error C2664: 'setvbuf' : cannot convert parameter 2
from 'int' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast,
C-style cast or function-style cast

(cc = MS compiler shell script wrapper)

Since the test will fail in the normal case - output is some error, should
it not in the rare case of success return zero => [reversed = yes] and all
other cases => [reversed=no]? - Just a suggestion.

Thanks JB






reply via email to

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