Ticket #10660 (closed build error: fixed)
Conflict between _T macro and Sun Studio 12 headers
| Reported by: | jroemmler | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 2.8.11 |
| Component: | base | Version: | |
| Keywords: | _T() macro-conflict suncc | Cc: | lanurmi@…, Brian.Cameron@… |
| Blocked By: | Patch: | no | |
| Blocking: |
Description
Hi,
I'm compiling and using wxWidgets library in various versions and platforms on a number of different machines. Lately, I came across a serious problem with macro _T which is defined in wxWidgets header files (see http://docs.wxwidgets.org/stable/wx_stringfunctions.html#underscoret). A simple "program" like this won't compile any longer:
// file bad.cpp #include <wx/wx.h>
# /opt/SUNWspro/bin/CC -V
CC: Sun C++ 5.8 Patch 121018-18 2009/02/25
# /opt/SUNWspro/bin/CC -I/usr/local/wxWidgets-2.6.3/build_Motif_CC_shared/lib/wx/include/motif-ansi-release-2.6 -I/usr/local/wxWidgets-2.6.3/include -I/usr/local/wxWidgets-2.6.3/contrib/include -D__WXMOTIF__ -I/usr/openwin/include -I/usr/dt/include -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -xarch=amd64 -o /dev/null -c bad.cpp
"/opt/SUNWspro/prod/include/CC/Cstd/./memory", line 107: Error: Type name expected instead of "{".
"/opt/SUNWspro/prod/include/CC/Cstd/./string", line 850: Where: While specializing "__rwstd::__rw_basis<__rwstd::_T, __rwstd::_Base>".
"/opt/SUNWspro/prod/include/CC/Cstd/./string", line 850: Where: Specialized in std::string .
"/opt/SUNWspro/prod/include/CC/Cstd/./stdexcept", line 65: Where: Specialized in non-template code.
The problem is because _T is also used in template code by latest Sun Studio (11 and 12) STL header files (see my posting here: http://forums.sun.com/thread.jspa?threadID=5376645). I think using names with underscore-prefix in (public) header files is definitely a bad idea.
My suggestion for wxWidgets 3.0 would be to break source code compatibility and get rid of _T() (and _() while we're at it); using existing wxT() instead is a simple search'n'replace operation - or making it a #define like so:
#ifdef wxUSE_DEPRECATED_T_MACRO
#define _T ...
#else
// do not define _T because it may lead to name clashes in user code
// or STL compiler header files.
#endif
What do you think?
Jochen

