Re: [AD] Proposal for new Allegro interface

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


In reply to Sven Sandberg <svsa1977@xxxxxxxxxx>:
[snip]
>Nice! Is `namespace' a standard feature and supported by all compilers?

Well, it is the C++ standard. It is supposed to replace the keyword
`static'.

>I didn't know about it, but if it works, then it seems to solve a lot of
>problems. But at least one problem remains: In C, if someone does:
>
>   #include "myfile.h"
>   #include <allegro.h>
>   void foo(void)
>   {
>      KEY_STRUCT k;
>      k.key = 1;
>   }
>
>where myfile.h declares
>
>   typedef struct
>   {
>      int key;
>   } KEY_STRUCT;
>
>then `key' will be renamed after but not before allegro.h was included
>so it gives a compiler error on the line `k.key = 1'. It is easily
>solved by the programmer (just move #include <allegro.h> to the top of
>each file), but not everyone who compiles a program is the person who
>wrote it and not even everyone is a programmer. I don't know how common
>this problem is though.

Annoying. This does cause a problem -- can we expect users to accept the
following:

 - If you use the old-style allegro functions, then you must include 
   "allegro.h" before any of your own code, in case any of your
   structure members' names clash with anything redefined. Including
   "allegro.h" first will solve this problem, however.

This could well require a change to user's code, unlike anything else I
have proposed. Is this reasonable?

[snip]
>There's also another problem with the unused static functions that I
>forgot to mention: msvc 5 with warning level 4, and watcom, and possibly
>other non-gcc-compilers, will generate tons of warnings for all programs
>that use old names because most of the static inline functions will be
>unused. I don't think this can be fixed without either converting the
>file to use the prefixed API and #define NO_ALIAS, or remove the
>warning. Maybe I'm overworried, but I just want to shed some light on
>the problems before they arise.

MSVC's warning can be turned off, as can gcc's. I expect there is some
mechanism for the other compilers as well.

Bye for now,
-- 
Laurence Withers, lwithers@xxxxxxxxxx
                http://www.lwithers.demon.co.uk/

Attachment: signature.asc
Description: PGP signature



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