OUTPUT : error: initializer element is not constantCode:int i=10; int j=i; int main() { printf("%d \n",j); return 0; }
Please anyone give explanation on above error.
OUTPUT : error: initializer element is not constantCode:int i=10; int j=i; int main() { printf("%d \n",j); return 0; }
Please anyone give explanation on above error.
You are initializing the variable with another variable.
Quzah.
Hope is the first step on the road to disappointment.
Is this only not allowed for global variables? If "i" was "const", would this then be allowed (as global), since the value of "i" is known at compile-time? N.B. Please dont say "try it" as thats obvious, Id rather understand it.Originally Posted by quzah
You may do like so in global,
The problem has to do with the instantiation of a 'variable' type, say it out loud and you'll see why. ;DCode:#define evil 666 const unsigned int lolwat = evil;
\/
Last edited by since; 12-09-2009 at 02:27 PM.
hi ,
till now i am not clear my confusion about this problam.
Actually wt will hapen in load time? y variable value is not assigning.
wts internal machanisam going on in compile and load time?
Global variables may only take constant initializers. It's obvious that the compiler could in PRINCIPAL figure out what to do, but it's not in the standard. It needs to be a constant.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}