Advertisement

pointers arrrrg help

Started by March 11, 2000 09:37 PM
0 comments, last by slugster 24 years, 7 months ago
starcpu.h struct STARSCREAM_PROGRAMREGION { unsigned lowaddr; unsigned highaddr; unsigned offset; };__________________________________________________________ i also tried struct STARSCREAM_PROGRAMREGION { unsigned lowaddr; unsigned highaddr; unsigned *offset; };________________________________ main.c #include "68k/starcpu.h" #include unsigned char *ram; struct STARSCREAM_PROGRAMREGION pretend_programfetch[] = { {0x000000, 0x3fffff, (unsigned)ram }, {-1, -1, NULL} }; main(){ ..malloc and othe stuff here but ignore this for now }; this give me a error when i compileit like above. src/memmap.c:8: initializer element is not constant src/memmap.c:8: (near initialization for `pretend_programfetch[0].offset'') make.exe: *** [obj/memmap.o] Error 1 but NULL works fine, if i do this it works fine main.c #include "68k/starcpu.h" #include unsigned char *ram; struct STARSCREAM_PROGRAMREGION pretend_programfetch[] = { {0x000000, 0x3fffff, NULL }, {-1, -1, NULL} }; main(){ ..malloc and othe stuff here but ignore this for now pretend_programfetch[0].offset=(unsigned)rom; }; why cant i use this in the structure i am using djgpp (the dos port of gcc) i want the information in a structure but i doesnt look like c will allow it
C doesn''t like initializing structures with dynamic values. I would recommend compiling as C++ instead if you want to initialize a structure member with a variable.

This topic is closed to new replies.

Advertisement