extern "C"

This is a discussion on extern "C" within the c++ forums in Programming Languages category; Ben Bacarisse wrote: > Ian Collins <ian-news @ hotmail.com> writes: > >> Ben Bacarisse wrote: >>> Jerry Coffin <jcoffin @ taeus.com> writes: >>>>> Most c++ compiler support C99 unless you disable it in the command line. >>>> Really? All the C++ compilers I have handy seem to reject the following >>>> perfectly legal bit of C99 code: >>>> >>>> union { >>>> char birthday[9]; >>>> int age; >>>> float weight; >>>> } people = { .age = 14 }; >>>> >>> Recent versions of gcc accept it. >>> >> gcc also accepts VLAs, but I doubt any other C++ compiler ...

Go Back   Application Development Forum > Programming Languages > c++

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #21  
Old 09-06-2008, 07:10 PM
Ian Collins
Guest
 
Default Re: extern "C"

Ben Bacarisse wrote:
> Ian Collins <ian-news@hotmail.com> writes:
>
>> Ben Bacarisse wrote:
>>> Jerry Coffin <jcoffin@taeus.com> writes:


>>>>> Most c++ compiler support C99 unless you disable it in the command line.
>>>> Really? All the C++ compilers I have handy seem to reject the following
>>>> perfectly legal bit of C99 code:
>>>>
>>>> union {
>>>> char birthday[9];
>>>> int age;
>>>> float weight;
>>>> } people = { .age = 14 };
>>>>


>>> Recent versions of gcc accept it.
>>>

>> gcc also accepts VLAs, but I doubt any other C++ compiler would.

>
> I mean gcc accepts it when invoked with '-std=c99'. Jerry Coffin said
> it did not. I am reporting that at least some recent versions do (as
> they must if they want to compile C99).
>
> For the record, the same gcc correctly rejects (or at least diagnoses)
> VLAs when invoked as a conforming C++ compiler. The presence of a
> default mixed mode where a compiler accept some odd half-language plus
> extensions is unfortunate but common.
>

That (gcc correctly rejects VLAs in C++ mode) is good. One of my worst
poring form gcc to standard C++ nightmares was scores of gcc VLAs.

--
Ian Collins.
Reply With Quote
  #22  
Old 09-06-2008, 10:37 PM
Jerry Coffin
Guest
 
Default Re: extern "C"

In article <878wu5ieu0.fsf@bsb.me.uk>, ben.usenet@bsb.me.uk says...

[ ... ]

> Recent versions of gcc accept it.


I'm glad to hear that. What I was using isn't exactly current, but it's
not terribly old either -- it's good to hear that they're apparently
making a real attempt at C99 compliance (finally...)

--
Later,
Jerry.

The universe is a figment of its own imagination.
Reply With Quote
  #23  
Old 09-08-2008, 06:07 AM
Michael DOUBEZ
Guest
 
Default Re: extern "C"

Jerry Coffin a écrit :
> In article <48c0dbfe$0$17346$426a74cc@news.free.fr>,
> michael.doubez@free.fr says...
>
> [ ... ]
>
>> Most c++ compiler support C99 unless you disable it in the command line.

>
> Really? All the C++ compilers I have handy seem to reject the following
> perfectly legal bit of C99 code:
>
> union {
> char birthday[9];
> int age;
> float weight;
> } people = { .age = 14 };
>


True. I have overly generalized.
I was thinking of VLAs which tends to creep in so often. This code is
however accepted by my IAR c++ compiler.

More compliant c++ compiler will hopefully reject this code. But I guess
one could tweak them into accepting it.

--
Michael
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:40 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.