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: initializer must be constant error bug? - comp.compilers.lcc ...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 ... SWITCH expression must be a scalar or string constant - comp.soft ...initializer must be constant error bug? - comp.compilers.lcc ... SWITCH expression must be a scalar or string constant - comp.soft ... initializer must be constant error ... Static const integral data members can be initialized? - comp.lang ...initializer must be constant error bug? - comp.compilers.lcc ... Static const integral data members can be initialized? - comp.lang ... initializer must be constant error ... VHDL-2002 vs VHDL-93 vs VHDL-87? - comp.lang.vhdlinitializer must be constant error bug? - comp.compilers.lcc ... VHDL-2002 vs VHDL-93 vs VHDL-87? - comp.lang.vhdl initializer must be constant error bug? - comp.compilers ... const reference typedef compile error: - comp.lang.c++.moderated ...initializer must be constant error bug? - comp.compilers.lcc ... const reference typedef compile error: - comp.lang.c++.moderated ... initializer must be constant error ... static library + undefined reference problem - comp.compilers.lcc ...Static const integral data members can be initialized? - comp.lang ... Static const integral data members can be initialized? - comp.lang ... must be constant error bug ... tuple and brace initializer - why not - comp.lang.c++.moderated ...... this works but return {i,d}; } I get Tuple.C:11:14: error ... of them accept special syntax (braces ... in MikTex 2.9 --- bug? - comp.text.tex ... initializer must ... Explanation needed for const int "error: variably modified ... at ...... 8192; char eodContents[eodSize]; error: variab... ... have stated that a const object with an >> initializer that's a constant ... http://www.ghoti.net/~kst> Nokia "We must do ... Initialization of reference to non-const - comp.lang.c++.moderated ...error: initial value of reference to non-const must be an lvalue (while, btw Vis C++ 8 happily goes along ... In C++ temporaries cannot be bound to non-constant references ... lcc or gcc ,which better? - comp.compilers.lccTo understand the situation even better, try pointers ... expression of type 'const value_type' Note that GCC ... must be constant error bug? - comp.compilers.lcc ... initializer must be constant error bug? - comp.compilers.lcc ...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 ... Compiler Error C2099 (C++) - Microsoft Corporation: Software ...This error is issued only by the C compiler and occurs only for non ... variables at the start of the program and the values they are initialized with must be constant. 7/23/2012 7:06:07 PM
|