Multi-Dimensional array declaration not compiling anymore

Other misc things
Post Reply
zx81ultra
Member
Posts: 38
Joined: Thu Feb 13, 2020 1:56 am

Multi-Dimensional array declaration not compiling anymore

Post by zx81ultra »

Hello z88dk community,

I hope this message finds you well. After a bit of a hiatus, I've recently found some time to delve back into tinkering with z88dk on the Sinclair ZX81. However, I've hit a roadblock while compiling my old code that once worked seamlessly.

The problem arises with this type of array declaration:

Code: Select all

const unsigned char HighResPatterns[][]= { 	// rom idx 26	pseudo hires udg characters													  
{188,188,188,188,188,188,188,188}, 		// SN_BLANK 				0
{ 60, 60, 60, 60, 60, 60, 60, 60}, 		// SN_WALL 					1
{ 60,148,148,148,148,148,148, 60},		// SN_TAIL 					2
{ 39, 39, 39, 60, 60, 39, 39, 39}  		// SN_HEAD 					3
};
Previously, on an Intel Mac using a 2020 version of z88dk, this declaration worked flawlessly. Now that I switched to an Apple Silicon Mac and installed the latest z88dk version, I'm encountering the following error: "fatal error: Must specify array dimension of type: const unsigned char []".

Thank you in advance for your valuable help.

Best regards,
Camilo.
User avatar
dom
Well known member
Posts: 2304
Joined: Sun Jul 15, 2007 10:01 pm

Re: Multi-Dimensional array declaration not compiling anymore

Post by dom »

I can't pinpoint when the change happened, but it's actually consistent with other compilers:

Code: Select all

dom@ermintrude z88dk % zcc +test arr.c -compiler=sccz80
arr.c:1:40: fatal error: Must specify array dimension of type: const unsigned char []
Compilation aborted
dom@ermintrude z88dk % zcc +test arr.c -compiler=sdcc
arr.c:1: error 66: attempt to allocate variable of unknown size 'HighResPatterns'
dom@ermintrude z88dk % gcc arr.c
arr.c:1:36: error: array has incomplete element type 'const unsigned char []'
const unsigned char HighResPatterns[][]= {      // rom idx 26   pseudo hires udg character...
                                   ^
1 error generated.
To fix, do this:

Code: Select all

const unsigned char HighResPatterns[][8]= {
zx81ultra
Member
Posts: 38
Joined: Thu Feb 13, 2020 1:56 am

Re: Multi-Dimensional array declaration not compiling anymore

Post by zx81ultra »

Thank you Dom !

I'm modifying my code with this new compiler behavior.

Best regards.
Post Reply