i have come across a bit of code that isn't compiling properly, and was wondering if it is just written wrong. The file that it is in is a C program, not a C++, so if any one knows if its wrong and can tell me how to fix it please do:
uint64_t al_ffblk_get_size(struct al_ffblk *info) { ASSERT(info); struct FF_DATA *ff_data = (struct FF_DATA *) info->ff_data; return ff_data->data.ff_fsize; }
Why isn't it compiling properly?
Posting compiler error messages would probably help you avoid answering lots of questions
struct FF_DATA *ff_data = (struct FF_DATA *) info->ff_data;
Looks to me like you're trying to mix compile time initialization with run time variables...
it has told me that there is a parse error before 'struct' and then says that ff_data is undeclared
EDIT:
Looks to me like you're trying to mix compile time initialization with run time variables...
there are several places in the original file that this works, but the code i wrote at the beggining of this poste is at the end of the file and is the only thing not compiling
Probably that you're trying to declare struct FF_DATA *ff_data after the ASSERT() call, and only the newest C99 compliant C compilers will allow that (MSVC is not C99 compliant, as an FYI). Also, is struct FF_DATA defined anywhere? Why are you defining Allegro's function in your code?
would flipping the first and second lines of the function fix the problem?
as for:
Why are you defining Allegro's function in your code?
its not my code. It is dfile.c of allegro's source code.
Why are you messing around with Allegro code? It should work perfectly on all decent compilers.
when compiling allegro for djgpp i get this error:
src/dos/dfile.c: In function `al_ffblk_get_size':
src/dos/dfile.c:340: parse error before `struct'
src/dos/dfile.c:342: `ff_data' undeclared (first use in this function)
src/dos/dfile.c:342: (Each undeclared identifier is reported only once
src/dos/dfile.c:342: for each function it appears in.)
src/dos/dfile.c:343: warning: control reaches end of non-void function
make.exe: *** [obj/djgpp/alleg/dfile.o] Error 1
this is the same for optimized, debugging and Profiling modes, and the install forum couldn't tell me why.
What version of GCC does your version of DJGPP use?
ive used versions 4.10 and 2.9.5.3 and i get the same error.
EDIT:
this is the original post to the install forum.
http://www.allegro.cc/forums/thread/590431
i had started having this problem with watcom and was told to use djgpp and ended up with some of the same problems.