gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > problems with compiling with dev-c++

#20246 - mr_schmoe - Wed May 05, 2004 3:49 pm

ok, this one's got me completely baffled. I think I have dev-c++ working, I followed the instructions on this other post.
http://forum.gbadev.org/viewtopic.php?t=1736&start=0&postdays=0&postorder=asc&highlight=devc
But when I try to compile a simple demo, I get this error:

Compiler: GBA compiler
Building Makefile: "D:\devkitadv\projects\devc++\Makefile.win"
Executing make...
make.exe -f "D:\devkitadv\projects\devc++\Makefile.win" all
gcc.exe -c main.cpp -o main.o

main.cpp: In function `int main()':
main.cpp:16: invalid types `int[int]' for array subscript
make.exe: *** [main.o] Error 1

Execution terminated

here's the code:

Code:
#include "gba.h"

int main()
{
    SetMode(MODE_3);
    u16 a;
    int i = 0;
   
    for (a = 0; a < 240 * 10; a++)
    {
        VideoBuffer[i++] = 31;
    }
    return 0;
}


any suggestions?

or an here's how I defined the videobuffer:

Code:
#define  VideoBuffer (u16*)0x6000000

#20247 - poslundc - Wed May 05, 2004 4:27 pm

Your macro is being translated into code as follows:

Code:
(u16*)0x6000000[i++] = 31;


... which is illegal. To fix it, put parentheses around your #define:

Code:
#define      VideoBuffer   ((u16 *)0x6000000)


... and it should work.

Dan.