Re: in-class initialization of fundamental types
Re: in-class initialization of fundamental types
- Subject: Re: in-class initialization of fundamental types
- From: Markian Hlynka <email@hidden>
- Date: Fri, 23 Sep 2005 22:58:25 -0600
On Sep 23, 2005, at 16:38, Jerry Krinock wrote:
on 05/09/23 15:23, Markian Hlynka at email@hidden wrote:
Isn't the following suppposed to be legal in c++?
class foo
{
public:
static const int foo_max_size = 100;
private:
char fooname[foo_max_size];
};
xcode (and thus gcc4) doesn't seem to allow it, but I was certain I'd
read somewhere that this was now legal??
I didn't think so, but to my surprise I pasted your declaration
into a .mm
file in my CodeWarrior Objective-C++ project and CodeWarrior
compiled it
without complaint. For what it's worth.
I believe this is a recent addition/standardization. I haven't had a
chance to try it with gcc4 for linux, but I have a friend who knows
everything about C++, and he said a) it is "now" legal (whetever that
means) and b) that "of course" the mac gcc doesn't do it yet, because
they're always behind. Don't flame me! The guy in question does a
small amount of cross-compiling on the mac, so if he has gripes, at
the very least he's come across them honestly. I don't know enough to
say either way.
The same guy also informed me that the trick used traditionally to
overcome this is:
class foo
{
public:
enum {foo_max_size = 100};
private:
char fooname[foo_max_size];
};
neat trick, huh? Of course, I'd rather it wasn't necessary.
Markian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden