Compile warnings

SGDK only sub forum

Moderator: Stef

Post Reply
orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Compile warnings

Post by orlanrod » Sun Oct 11, 2015 3:27 am

Been getting these warnings in codeblocks. Been ignoring them until now.

src\main.c||In function `main':|
src\main.c|75|warning: passing arg 2 of `VDP_setPaletteColors' discards qualifiers from pointer target type|
src\main.c|113|warning: passing arg 2 of `SPR_initSprite' discards qualifiers from pointer target type|
src\main.c|114|warning: passing arg 2 of `SPR_initSprite' discards qualifiers from pointer target type|


Here is the code related to the errors

VDP_setPaletteColors(0, palette_black, 64);
PR_initSprite(&sprites[player1.zorder], &jason_sprite, player1.x, player1.y, TILE_ATTR(PAL1, TRUE, FALSE, FALSE));
SPR_initSprite(&sprites[czorder], &fcitizen_sprite, cxypos[0][0], cxypos[1][0], TILE_ATTR(PAL2, TRUE, FALSE, FALSE));

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Compile warnings

Post by Stef » Sun Oct 11, 2015 7:46 am

You can ignore these ones freely, that are just because of "const" versus "no const" variables ;)

orlanrod
Very interested
Posts: 99
Joined: Fri Sep 25, 2015 7:46 pm

Re: Compile warnings

Post by orlanrod » Sun Oct 11, 2015 4:55 pm

Stef wrote:You can ignore these ones freely, that are just because of "const" versus "no const" variables ;)
Ah okay. Will do. 8B

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: Compile warnings

Post by tryphon » Mon Oct 12, 2015 1:28 pm

Is there a way of fixing them (I mean, apart casting everything) (some tag in the make.exe...) ?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Compile warnings

Post by Stef » Mon Oct 12, 2015 3:22 pm

I don't think so, i can remove all the 'const' from the method declaration side, but you sometime want to have it in the variable declaration so... there is no good solution to avoid them as far i know :-/

mikejmoffitt
Very interested
Posts: 86
Joined: Fri Sep 25, 2015 4:16 pm

Re: Compile warnings

Post by mikejmoffitt » Mon Oct 12, 2015 8:47 pm

For setting the palette, you can just do this:

Code: Select all


u32 p_addr = (u32)(address of your palette array; 16 words);
// Could be u32 p_addr = (u32)&my_pal[0];
u16 pal_number = (palette you want to set);
VDP_doCRamDMA(p_addr, pal_number * 32, 16);


Post Reply