initializer must be constant error bug? #2

  • Follow


Jacob,

I sent this once, not sure if it went through?

I'm getting the error " initializer must be constant" from code such as:

void foo(int x, int y, int w, int h)
{
RECT rc = { x,y,w,h };
}

This should work for auto variables, correct?

Thanks,
Mike H.

0
Reply Mike 1/24/2006 4:07:50 AM

"Mike H." wrote:
> 
> I'm getting the error " initializer must be constant" from code such as:
> 
> void foo(int x, int y, int w, int h)
> {
> RECT rc = { x,y,w,h };
> }
> 
> This should work for auto variables, correct?

No.  The initializers must be constants.  Not 'const's.

-- 
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>


0
Reply CBFalconer 1/24/2006 7:19:28 AM


"Mike H." <mikehg_67@yahoo.com> writes:
> I sent this once, not sure if it went through?
>
> I'm getting the error " initializer must be constant" from code such as:
>
> void foo(int x, int y, int w, int h)
> {
> RECT rc = { x,y,w,h };
> }
>
> This should work for auto variables, correct?

You might try asking in comp.lang.c.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply Keith 1/24/2006 8:02:04 AM

"Mike H." <mikehg_67@yahoo.com> wrote in message 
news:43d5a8db$0$9239$6d36acad@titian.nntpserver.com...
>
> I'm getting the error " initializer must be constant" from code such as:
>
> void foo(int x, int y, int w, int h)
> {
> RECT rc = { x,y,w,h };
> }
>
> This should work for auto variables, correct?

Nope, not in C89. In both C99 and C++ that would be correct.

-- 
Unicals Group -- Embedded C++ for Your IP Cores
http://www.unicals.com


0
Reply Ivan 1/24/2006 9:49:12 AM

Ivan A. Kosarev wrote:
> "Mike H." <mikehg_67@yahoo.com> wrote in message 
> news:43d5a8db$0$9239$6d36acad@titian.nntpserver.com...
> 
>>I'm getting the error " initializer must be constant" from code such as:
>>
>>void foo(int x, int y, int w, int h)
>>{
>>RECT rc = { x,y,w,h };
>>}
>>
>>This should work for auto variables, correct?
> 
> 
> Nope, not in C89. In both C99 and C++ that would be correct.
> 

I thought Lcc-Win32 was being updated to support C99, maybe not 
implemented yet?, or a switch I'm missing?

Mike H.
0
Reply Mike 1/24/2006 12:23:12 PM

"Mike H." <mikehg_67@yahoo.com> wrote in message 
news:43d61cf5$0$9250$6d36acad@titian.nntpserver.com...
> Ivan A. Kosarev wrote:
>> "Mike H." <mikehg_67@yahoo.com> wrote in message 
>> news:43d5a8db$0$9239$6d36acad@titian.nntpserver.com...
>>
>>>void foo(int x, int y, int w, int h)
>>>{
>>>RECT rc = { x,y,w,h };
>>>}
>>>
>>>This should work for auto variables, correct?
>>
>> Nope, not in C89. In both C99 and C++ that would be correct.
>>
> I thought Lcc-Win32 was being updated to support C99, maybe not 
> implemented yet?, or a switch I'm missing?

Oh, if that wasn't accepted by your LCC-Win32 in C99-compatibility mode, 
it's certainly a defect then.

-- 
Unicals Group -- Embedded C++ for Your IP Cores
http://www.unicals.com


0
Reply Ivan 1/24/2006 8:19:49 PM

5 Replies
545 Views

(page loaded in 0.11 seconds)

Similiar Articles:













7/23/2012 7:06:07 PM


Reply: