Problem with g++ Ubuntu!

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Problem with g++ Ubuntu!

Post 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????
Image
User avatar
BugInTheSYS
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 88
Joined: Mon Feb 07, 2011 4:16 pm
Current Project: Vintage Roads
Favorite Gaming Platforms: PC
Programming Language of Choice: C++, Delphi
Location: Pinneberg, Germany
Contact:

Re: Problem with g++ Ubuntu!

Post 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.
Someday, everything will go to /dev/null. - Bug's prophecy 13:37
Post Reply