mettli / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

Constant DELETE under Windows bad solution in 0.8.1 #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have just ported some Code using guichan 0.8.0 from Linux to Windows and
I found the Problem with DELETE in:
include/guichan/key.hpp
because it is already defined in winnt.h (mingw)
The solution in 0.8.1:

#if defined (_WIN32) && defined(DELETE)
#undef DELETE
#endif

is bad IMHO.

Why not changing the name of the constant from DELETE into DEL?
I solved it here for me with this patch (Line-Numbers from 0.8.0):

    include/guichan/key.hpp line 135
    src/allegro/allegroinput.cpp line 376 + 380
    src/hge/hgeinput.cpp line 321 + /* 326 */
    src/sdl/sdlinput.cpp line 288
    src/widgets/textbox.cpp line 291 + 288
    src/widgets/textfield.cpp line 169
-            DELETE
+            DEL

chears,
Raphael Gradenwitz

Original issue reported on code.google.com by raphael....@googlemail.com on 21 May 2008 at 7:33

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/guichan/issues/detail?id=36&can=1&q=delete

Renaming DELETE to DEL is ugly in my opinion because DEL doesn't follow our 
naming
convention. Of course, it excludes the usage of native windows code - such as a 
pure
windows input backend - but there is no such back end present at the moment.

What do you other guys think? Should we rename DELETE to DEL and pray that DEL 
is not
defined by some other header just to make it possible to use Guichan with native
windows code?

Original comment by olof.nae...@gmail.com on 21 May 2008 at 8:16

GoogleCodeExporter commented 9 years ago
Both "solutions" are hacky and ugly. 

The main problem is, of course, that the names used in the enum are very 
generic, 
like DELETE, but END or ENTER may also easily clash with definitions elsewhere. 

Macros don't respect namespaces, so I guess the only proper solution will be to 
only 
use names here that are probably not used as macros. Like GCN_DELETE or GCN_END 
and 
such, thus imitating namespaces by prefixes. 

Original comment by tob...@gmx.net on 22 May 2008 at 7:51

GoogleCodeExporter commented 9 years ago
What about dropping the uppercasing? It's not very common to do that in a C++ 
enum
anyway, and I'm sure it's rather unlikely that there's a macro called "Delete".

Original comment by b.lindeijer on 11 Jun 2008 at 8:57

GoogleCodeExporter commented 9 years ago
That's a very good idea.

Original comment by olof.nae...@gmail.com on 11 Jun 2008 at 3:55

GoogleCodeExporter commented 9 years ago
So should we do this for all enums in Guichan? Guichan-using projects will love 
it! :-P

Original comment by b.lindeijer on 15 Jul 2008 at 10:04

GoogleCodeExporter commented 9 years ago
I guess so :) It's by far the best solution in my opinion.

Original comment by olof.nae...@gmail.com on 15 Jul 2008 at 11:03

GoogleCodeExporter commented 9 years ago
All enum names have changed. They are now named as classes.

Original comment by olof.nae...@gmail.com on 4 Aug 2008 at 10:56