Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > g++ thingy

Reply
Thread Tools

g++ thingy

 
 
keith
Guest
Posts: n/a
 
      02-14-2010
Why does g++ 4.3.4 accept this struct declaration?

struct A
{
static float const c = .5;
};

This compiles ok, I can reference the constant without any problems. The
linker gives no errors.
 
Reply With Quote
 
 
 
 
Robert Fendt
Guest
Posts: n/a
 
      02-14-2010
And thus spake keith <(E-Mail Removed)>
Sun, 14 Feb 2010 17:16:36 +0100:

> Why does g++ 4.3.4 accept this struct declaration?


Hint: retry with -pedantic -ansi -Werror.

Your question is essentially the same as "Why do compiler
manufacturers implement non-standard extenstions?"

Answer: mainly because they can, and because some extensions
_are_ useful, if one is not interested in portability.

Regards,
Robert

 
Reply With Quote
 
 
 
 
Marcel Müller
Guest
Posts: n/a
 
      02-14-2010
keith wrote:
> Why does g++ 4.3.4 accept this struct declaration?
>
> struct A
> {
> static float const c = .5;
> };


Why shouldn't it?


Marcel
 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      02-14-2010
Marcel Müller wrote:

> keith wrote:
>> Why does g++ 4.3.4 accept this struct declaration?
>>
>> struct A
>> {
>> static float const c = .5;
>> };

>
> Why shouldn't it?


Because the C++ standard doesn't allow it.

 
Reply With Quote
 
keith
Guest
Posts: n/a
 
      02-14-2010
> Hint: retry with -pedantic -ansi -Werror.

Thanks.

> Your question is essentially the same as "Why do compiler
> manufacturers implement non-standard extenstions?"
>
> Answer: mainly because they can, and because some extensions
> _are_ useful, if one is not interested in portability.


I don't agree completely, as gcc is present on many architectures, or
rather, as gcc is itself very portable, portability does not suffer much
if one uses its extensions.

Maybe this g++ extension is documented somewhere?
 
Reply With Quote
 
keith
Guest
Posts: n/a
 
      02-14-2010
>> Why does g++ 4.3.4 accept this struct declaration?
>>
>> struct A
>> {
>> static float const c = .5;
>> };

>
> Why shouldn't it?


it's non-standard.
 
Reply With Quote
 
Vaclav Haisman
Guest
Posts: n/a
 
      02-14-2010
Marcel Müller wrote, On 14.2.2010 18:24:
> keith wrote:
>> Why does g++ 4.3.4 accept this struct declaration?
>>
>> struct A { static float const c = .5; };

>
> Why shouldn't it?

Because IIRC only integral types constants can be initialized at the
declaration like that.


--
VH


 
Reply With Quote
 
Andrew Poelstra
Guest
Posts: n/a
 
      02-14-2010
On 2010-02-14, keith <(E-Mail Removed)> wrote:
>> Hint: retry with -pedantic -ansi -Werror.

>
> Thanks.
>
>> Your question is essentially the same as "Why do compiler
>> manufacturers implement non-standard extenstions?"
>>
>> Answer: mainly because they can, and because some extensions
>> _are_ useful, if one is not interested in portability.

>
> I don't agree completely, as gcc is present on many architectures, or
> rather, as gcc is itself very portable, portability does not suffer much
> if one uses its extensions.
>


Nonetheless, C++ is far more portable than "GNU C++" and
also far less likely to change without warning.

> Maybe this g++ extension is documented somewhere?


 
Reply With Quote
 
Krice
Guest
Posts: n/a
 
      02-14-2010
On 14 helmi, 19:46, keith <(E-Mail Removed)> wrote:
> portability does not suffer much if one uses its extensions.


Actually it suffers a lot from non-standard extensions
used by ignorant simpletons. But you don't seem to be a
kind of guy who knows something about portability.
 
Reply With Quote
 
keith
Guest
Posts: n/a
 
      02-14-2010
Krice pravi:
> On 14 helmi, 19:46, keith <(E-Mail Removed)> wrote:
>> portability does not suffer much if one uses its extensions.

>
> Actually it suffers a lot from non-standard extensions
> used by ignorant simpletons. But you don't seem to be a
> kind of guy who knows something about portability.


All unsubstantiated assertions, especially since they come from a Java
programmer.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you attach this thingy? bigal Hardware 46 04-07-2006 05:14 AM
java dropdown transfer thingy question M.E. Java 0 06-22-2004 12:40 AM
remove windows startup logo thingy P.J. Computer Support 1 10-17-2003 10:54 PM
bucies image selector thingy David Graham HTML 4 07-03-2003 10:06 PM



Advertisments