Re: [AD] official beta (Re namespace again)

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


At 15:12 2001-10-30 -0700, Thomas Fjellstrom wrote:
>On October 30, 2001 05:59 am, you wrote:
>> In reply to Sven Sandberg <svsa1977@xxxxxxxxxx>:
>> >[allegro.h]
>> >   #define key al_key
>> >
>> >but this macro breaks code like:
>> >
>> >[myheader.h]
>> >   typedef struct{
>> >      int key;
>> >   }FOO;
>> >
>> >[mycode.c]
>> >   #include "myhead.h"
>> >   #include <allegro.h>
>> >   FOO x;
>> >   x.key=0;
>>
>> Yes, you are correct. This is one of the very few instances where there
>> is nothing we can do but ask users to change their code (in this case,
>> move the inclusion of `allegro.h' to below the definition of `FOO').
>
>what if FOO is defined as:
>
>struct {
>  BITMAP *key;
>} FOO;

In such cases the advice could be to change it to
struct BITMAP; /* This declaration is not necessary in this case */
struct {
  struct BITMAP *key;
} FOO;
which is also better code since it does not expose the definition of `struct BITMAP' when not needed. Using typenames when not necessary will in general tie modules harder together, e.g. suppose that bar.c needs stuff exported in myheader.h but uses not Allegro, then it should not need to include allegro.h.

/Christer




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