[Top][All Lists]

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

Re: Autoconf 2.69 AC_PROG_CXX accepts plain C compilers

From: Eric Blake
Subject: Re: Autoconf 2.69 AC_PROG_CXX accepts plain C compilers
Date: Wed, 05 Feb 2014 14:44:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 02/05/2014 02:36 PM, Peter De Wachter wrote:
> On 05-02-14 21:40, Eric Blake wrote:
>> Actually, in gcc's case, your proposed program is now a syntax error:
>> $ gcc -o foo foo.c
>> foo.c: In function ‘main’:
>> foo.c:1:21: error: ‘new’ undeclared (first use in this function)
>>  int main() { (void) new int; return 0; }

> That's because you named the file "foo.c".
> $ gcc -o foo foo.cpp
> /tmp/ccVVxj3a.o: In function `main':

Oh - so the gcc frontend changes language syntax based on file
extension, but does NOT change the linker backend to match.  Then yes, I
agree that we have to force a linker error.

> 'delete new int' should work as well. But I don't think defining a class
> is sufficient. To catch GCC, you need something that will cause a link
> error. Something like this would work:
> #include <string>
> int main() { std::string s; return 0; }

Too complex to be reliable.

> But using the standard library is difficult if you want to support old
> compilers that don't have namespace support.

I think you've convinced me that going with 'delete new int' is the way
to go.  I'll wait another day or so before pushing, in case anyone else
has comments.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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