Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Is this how this is suppose to be written???

This thread is locked; no one can reply to it. rss feed Print
Is this how this is suppose to be written???
Alysher
Member #8,406
March 2007
avatar

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;
}

I didn't lose my marbles, I never had any to begin with!!!

CGamesPlay
Member #2,559
July 2002
avatar

Why isn't it compiling properly?

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

HoHo
Member #4,534
April 2004
avatar

Posting compiler error messages would probably help you avoid answering lots of questions :)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Arthur Kalliokoski
Second in Command
February 2005
avatar

Quote:

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...

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Alysher
Member #8,406
March 2007
avatar

it has told me that there is a parse error before 'struct' and then says that ff_data is undeclared

EDIT:

Quote:

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

I didn't lose my marbles, I never had any to begin with!!!

Kitty Cat
Member #2,815
October 2002
avatar

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?

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Alysher
Member #8,406
March 2007
avatar

would flipping the first and second lines of the function fix the problem?

as for:

Quote:

Why are you defining Allegro's function in your code?

its not my code. It is dfile.c of allegro's source code.

I didn't lose my marbles, I never had any to begin with!!!

HoHo
Member #4,534
April 2004
avatar

Why are you messing around with Allegro code? It should work perfectly on all decent compilers.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Alysher
Member #8,406
March 2007
avatar

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.

I didn't lose my marbles, I never had any to begin with!!!

HoHo
Member #4,534
April 2004
avatar

What version of GCC does your version of DJGPP use?

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Alysher
Member #8,406
March 2007
avatar

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.

I didn't lose my marbles, I never had any to begin with!!!

Go to: