Page 1 of 1

Problem with g++ Ubuntu!

Posted: Tue Feb 19, 2013 3:38 pm
by lalacomun
Well, i just installed Ubuntu, instaled g++, SDL,everything so i decided to make a simple sdl app so see if it works, and it compiled! but now im trying to port my engine, and it gives the following error:
a matrix is asigned from a list of initializer, the actuall error is in spanish: se asigna a una matriz desde una lista de inicializador i just translated, this was the problem:

Code: Select all

bool Array[4];

...

Array = {0,0,0,0};
so, i did the following thing to solve it:

Code: Select all

bool Array[4];

...

Array[0] = 0;
Array[1] = 0;
Array[2] = 0;
Array[3] = 0;
And, it compiled perfectly! buuuut! when i run the program it gives me an error:
Segment violation or in spanish: ViolaciĆ³n de segmento

Any suggestions????

Re: Problem with g++ Ubuntu!

Posted: Tue Feb 19, 2013 4:06 pm
by BugInTheSYS
lalacomun wrote:Well, i just installed Ubuntu, instaled g++, SDL,everything so i decided to make a simple sdl app so see if it works, and it compiled! but now im trying to port my engine, and it gives the following error:
a matrix is asigned from a list of initializer, the actuall error is in spanish: se asigna a una matriz desde una lista de inicializador i just translated, this was the problem:

Code: Select all

bool Array[4];

...

Array = {0,0,0,0};
Okay, 'lista de inicializador' translates to 'initializer list,' just so you know.
You can perfectly do this assignment when initializing, but in this case, you are assigning from an initializer list outside of an initialization. Either you initialize your array with an initializer list, or you have to do it the way you posted below.

Initialization is when you assign a value to a constant, a variable or an array the moment you declare them. You can only ever use initializer lists when initializing, not when the object is already defined.

As for the segfault: No idea why it happens, but I (and potentially also the others) need to see more code to answer that one.