Re: Fwd: Re: [AD] Custom packfiles

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Dustin Dettmer wrote:

Peter Wang wrote:
I only put in the prefix because getc and putc from
stdio.h can be macros and cause problems (which they did). It's also recommended practice in some standard to put prefixes on structure member names, for exactly this reason (e.g. that's why they have struct timeval { tv_sec, tv_usec }, and struct dirent { d_name, d_type }, etc.) -- not that anybody can be bothered most of the time.

Is Allegro C99?  If I understand the overloading
problem correctly, it could potientialy be solved via
variable macro arguments.  Although I may not be
understand the problem correctly, could you elaborate
on it?

The part you quoted is about the names of fields in structs. The following code has a problem:

struct PACKFILE_VTABLE {
   int (*getc)(PACKFILE *);
};

The problem is that stdio.h may have:

   #define getc(f)    ...

So you run into trouble when you try to write:

   x = vtable->getc(f);

Anyway, those are my thoughts and reasons for
prefering function overloading to cluttering up their names.

It's not a choice we have in C, and AFAIK C99 doesn't change that.

Peter




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/