how where arrays stored again?

P

Piotr Sawuk

I'm trying to re-compile some old ltris version, and got
ISO C++ forbids casting to an array type `int[12][400]'.
caused by the line

((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[(int)cur_y + by*BLOCKSIZE + b]

so I hope that in order to compile this I need to multiply i
by 400 and add the other stuff, or was it the other way around?
sorry, I'm not experienced with this old-code-repairing.
is int[a] an array of int[a] arrays or one of int arrays?
or is there an option for g++ to compile without any ISO-checking?
--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...

before complaining because of my rudeness, read
http://www.unet.univie.ac.at/~a9702387/en/adl/liar-faq.txt
and killfile me resp. google on friday night GMT...

P
 
V

Victor Bazarov

Piotr said:
I'm trying to re-compile some old ltris version, and got
ISO C++ forbids casting to an array type `int[12][400]'.
caused by the line

((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[(int)cur_y + by*BLOCKSIZE + b]

so I hope that in order to compile this I need to multiply i
by 400 and add the other stuff, or was it the other way around?
sorry, I'm not experienced with this old-code-repairing.
is int[a] an array of int[a] arrays or one of int arrays?
or is there an option for g++ to compile without any ISO-checking?


I'd probably use a typedef:

typedef int bowl_array[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE];

and then do this:

((bowl_array)bowl)[(int)cur_y + by*BLOCKSIZE + b]

If it doesn't work, try a reference to that array:

((bowl_array &)bowl)[(int)cur_y + by*BLOCKSIZE + b]

V
 
M

mlimber

Piotr said:
I'm trying to re-compile some old ltris version, and got
ISO C++ forbids casting to an array type `int[12][400]'.
caused by the line

((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[(int)cur_y + by*BLOCKSIZE + b]

so I hope that in order to compile this I need to multiply i
by 400 and add the other stuff, or was it the other way around?
sorry, I'm not experienced with this old-code-repairing.
is int[a] an array of int[a] arrays or one of int arrays?
or is there an option for g++ to compile without any ISO-checking?

[snip]

int[a] is a two-dimensional array with a rows and b columns. I'm
guessing this is old C code, which tends to be more lax on conversions.
Why don't you try a C compiler (e.g., gcc) rather than g++?

Cheers! --M
 
P

Piotr Sawuk

I'm trying to re-compile some old ltris version, and got
ISO C++ forbids casting to an array type `int[12][400]'.
caused by the line

((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[(int)cur_y + by*BLOCKSIZE + b]

so I hope that in order to compile this I need to multiply i
by 400 and add the other stuff, or was it the other way around?
sorry, I'm not experienced with this old-code-repairing.
is int[a] an array of int[a] arrays or one of int arrays?
or is there an option for g++ to compile without any ISO-checking?


hmmm, strangely the debugger is telling me that

&((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[0][0]

is a lot smaller than (int*)bowl, thereby making my whole idea of
emulating above construct in an iso-compilant c++-compiler useless.
basically it seems that in the situation with an error-message like

error: ISO C++ forbids casting to an array type `int[12][400]'

one is forced to completely re-write the definition and the logic
behind the involved types. it seems iso-c++ is in some cases a whole
different programming-language than old c++ or c, in that a complete
re-write is quite inevitable...
--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...

before complaining because of my rudeness, read
http://www.unet.univie.ac.at/~a9702387/en/adl/liar-faq.txt
and killfile me resp. google on friday night GMT...

P
 
P

Piotr Sawuk

I'm trying to re-compile some old ltris version, and got
ISO C++ forbids casting to an array type `int[12][400]'.
caused by the line

((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[(int)cur_y + by*BLOCKSIZE + b]

so I hope that in order to compile this I need to multiply i
by 400 and add the other stuff, or was it the other way around?
sorry, I'm not experienced with this old-code-repairing.
is int[a] an array of int[a] arrays or one of int arrays?
or is there an option for g++ to compile without any ISO-checking?


hmmm, strangely the debugger is telling me that

&((int[BOWL_W+2][BOWL_PIX_H+BLOCKSIZE])bowl)[0][0]

is a lot smaller than (int*)bowl, thereby making my whole idea of


just for the record:

(gdb) p &((int[12][400])bowl)[0][0]
$9 = (int *) 0x80bec98
(gdb) p bowl
$10 = (int *) 0x80c0de4
emulating above construct in an iso-compilant c++-compiler useless.
basically it seems that in the situation with an error-message like

error: ISO C++ forbids casting to an array type `int[12][400]'

one is forced to completely re-write the definition and the logic
behind the involved types. it seems iso-c++ is in some cases a whole
different programming-language than old c++ or c, in that a complete
re-write is quite inevitable...

--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...

before complaining because of my rudeness, read
http://www.unet.univie.ac.at/~a9702387/en/adl/liar-faq.txt
and killfile me resp. google on friday night GMT...

P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top