[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] patch to include curses.h only for CLI code
From: |
Vadim Zeitlin |
Subject: |
[lmi] patch to include curses.h only for CLI code |
Date: |
Fri, 13 Jun 2008 03:01:38 +0200 |
Hello,
Currently the Linux build fails because platform_dependent.hpp includes
curses.h which defines many macros with very common names. At least one of
them, namely "border", conflicts with this innocently-looking code from
wx/renderer.h:
wxSplitterRenderParams(wxCoord widthSash_, wxCoord border_, bool isSens_)
: widthSash(widthSash_), border(border_), isHotSensitive(isSens_)
{
}
and the compilation fails with mysterious error
wx/renderer.h:82:48: error: macro "border" requires 8 arguments, but only 1
given
I see several ways to correct this:
1. Add "#undef border" to wx/renderer.h with a comment explaining that this
identifier conflicts with a macro from curses.h.
I don't like this solution because it's presumably very rare that both
curses.h and wx headers are used by the same translation unit because
the former is only useful CLI and the latter for the GUI applications.
2. Add "#undef border" after curses.h inclusion to platform_dependent.hpp.
I still don't like this because there are a lot of other common macros
defined in curses.h which may break wx code compilation later in the
same mysterious way. And, worse, maybe definitions of some of these
macros already result in some (other) problems which are not detected
at compilation level. Besides, it really doesn't make much sense to use
both curses.h and wx headers simultaneously, which bring me to propose:
3. Only include curses.h when it's really needed, i.e. from files which are
(or may be) part of command line applications. Currently there is only
one such file using getch() which is apparently all we include curses.h
for. So there are actually 2 choices here:
a) Move curses.h or conio.h inclusion from platform_dependent.hpp to
alert_cli.cpp itself. As alert_cli.cpp doesn't include any wx headers
this solves the problem.
b) Keep the inclusion of curses.h in platform_dependent.hpp but only do it
if LMI_CLI is defined. The advantage of this approach is that it would
allow to easily use getch() from other files in the future.
So I attach the patch which implements 3(b) which seems like the least
intrusive solution to me. Please let me know if you prefer another one or
see a better way to solve this problem.
Thanks,
VZ
--- alert_cli.cpp 2008-01-13 17:16:43 +0000
+++ alert_cli.cpp 2008-06-13 00:55:57 +0000
@@ -26,6 +26,10 @@
# pragma hdrstop
#endif // __BORLANDC__
+// predefine LMI_CLI before including platform_dependent.hpp to include the
+// declaration of getch() which only makes sense for CLI programs
+#define LMI_CLI
+
#include "alert.hpp"
#include "platform_dependent.hpp" // getch()
--- platform_dependent.hpp 2008-02-06 03:50:22 +0000
+++ platform_dependent.hpp 2008-06-13 00:45:52 +0000
@@ -58,7 +58,9 @@
#endif // defined __GNUC__ && defined __STRICT_ANSI__
#if defined LMI_POSIX
-# include <curses.h> // getch()
+# ifdef LMI_CLI
+# include <curses.h> // getch()
+# endif
# include <stdio.h> // fileno()
# include <stdlib.h> // putenv()
# include <string.h> // strdup()
- [lmi] patch to include curses.h only for CLI code,
Vadim Zeitlin <=