[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-dev] The _R macro and ctype.h



 _R macro, see
http://www.xaraxtreme.org/developers/documentation/resource_system_introduction.html
and camresource.h around line 124

	// _R() is used 2860 times and so is non-trivial to change, but it is
	// defined <in ctype.h>

	// Are we right to use an _ macro, and if so, this one?

	// Define _R() before we include other Camelot headers
	// NOTE THIS MACRO IS EXPANDABLE IN A STATIC INITIALIZER
	#define _R(x) ( CamResource::GetResourceID( _RESQUOTE(x)) )

	In file included from ../Precomp/camtypes.h:115,
		/Volumes/Ben/PROG/SVN/XaraLX/wxOil/camresource.h:124:1: warning:
"_R" redefined
                 from /Volumes/Ben/PROG/SVN/XaraLX/xarapbx/wxOil_Prefix.h:7:
	                 from ../Precomp/camtypes.h:111,
		                 from /Volumes/Ben/PROG/SVN/XaraLX/wxOil/stdwx.h:102,
			                 from
/Volumes/Ben/PROG/WXWIDGETS/wxWidgets-2.6.3/include/wx/wx.h:15,
				                 from
/Volumes/Ben/PROG/WXWIDGETS/wxWidgets-2.6.3/include/wx/defs.h:503,
					                 from
/Volumes/Ben/PROG/WXWIDGETS/wxWidgets-2.6.3/include/wx/debug.h:22,
						In file included from
/Volumes/Ben/PROG/WXWIDGETS/wxWidgets-2.6.3/include/wx/wxchar.h:222,
							/usr/include/ctype.h:103:1: warning: this is the location of
the previous definition

wxWidgets includes ctype.h (arguably wrong in a unicode build), but
only when building on
BSD systems such as Darwin, and of course FreeBSD.

Personally, I would not use a symbol starting with an underscore
unless I was working on an
implementation or a framework, particlarly a short symbol, without a
very good reason.

So one solution would be to make a major change now, and replace the
_R macro with an _xR one  (an underscore symbol with a lowercase
letter is far less likely to cuase problems, and
adding the extra letter makes search and replace much easier if
problems/conflicts do arise later).

Alternatively, using the model that wxWidgets employs in '#undef _T'
at wxchar.h line 223, we
could '#undef _R' at say, line 113 of stdwx.h .

I am slightly surprised that Vasil Dimov from FreeBSD and Gerry Iles
(Xara) haven't come
across the same problem - or at least haven't commented on it, but it
is just conceivable that this
issue is Mac only.

Even so, if there is a common sense approach to avoiding name clashes
especially with the
pre-processor, I would be very tempted to adopt it, even if the
offered gain is small.

Ben