Donate Share

Templatized C++ Command Line Parser

Tracker: Bugs

5 MSVC /Zc:wchar_t- switch causes build failure - ID: 2870783
Last Update: Settings changed ( mes5k )

'Treat wchar_t as Built-In type' set to 'No' (/Zc:wchar_t-) causes a build
failure because of the duplicate template specialization caused by wchar_t
being typedef-ed as a unsigned short.

The full error is:

tclap-1.2.0\include\tclap\StandardTraits.h(175) : error C2766: explicit
specialization; 'TCLAP::ArgTraits<unsigned short>' has already been
defined
tclap-1.2.0\include\tclap\StandardTraits.h(106) : see previous
definition of 'ArgTraits<unsigned short>'

The solution I came up with is to not declare the specialization if the
compiler is MSVC and if wchar_t is not defined as a native type, something
like this:

#ifdef _MSC_VER
#ifndef _NATIVE_WCHAR_T_DEFINED
#define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS
#endif
#endif

Then do something like this in StandardTraits.h:

#ifndef TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS

template<>
struct ArgTraits<wchar_t> {
typedef ValueLike ValueCategory;
};

#endif


ChalkTrauma ( chalktrauma ) - 2009-09-30 14:36

5

Closed

Fixed

Mike Smoot

None

None

Public


Comment ( 1 )




Date: 2009-10-23 21:43
Sender: mes5kProject AdminAccepting Donations

Thanks for the patch, I just committed the change to CVS. This will make
it into the next release, whenever that happens.


Log in to comment.

Attached File

No Files Currently Attached

Changes ( 4 )

Field Old Value Date By
status_id Open 2009-10-23 21:43 mes5k
resolution_id None 2009-10-23 21:43 mes5k
assigned_to nobody 2009-10-23 21:43 mes5k
close_date - 2009-10-23 21:43 mes5k