0

I am attempting to get my Win32 C++ project to compile in Dev C++. The project was originally made in Visual Studio C++ 2010 so it uses alot of Unicode macro functions such as _tcscmp. _tcscat and most importantly _T.

I am attempting to get my project to compile in Dev C++ (Why? Its a long story but necessary). So I have attempted to define the macro function _T but I am getting a compiler error when this macro function is used: 'La' undeclared (first use this function)

Any ideas on where my macro function _T is going wrong?

#if IS_DEVCPLUSPLUS > 0

    #undef _T
    #define _T(a) La
#endif


// Compile error occurs on below line: "'La' undeclared (first use this function)"
_tcscat( fileName, _T("\\*") ); 

// The end result should be
_tcscat( fileName, L"\\*" );
nondescript
  • 149
  • 3
  • 7
  • @chris Thanks `L ##a` works. You should make an answer so I can accept – nondescript Feb 25 '14 at 03:07
  • There's not much point in a duplicate answer. Pointing people to the other answer (via a duplicate) would be better. – chris Feb 25 '14 at 03:08
  • 1
    The `_T` macro is reserved for the implementation. VC++ uses it for the Unicode/ASCII switch, but Dev-C++ may very well use it for other purposes. – MSalters Feb 25 '14 at 08:02

1 Answers1

0

The #define you're using, even if it worked for your compiler, is incomplete.

First, use the token pasting preprocessor symbol. Second, define _T(x) for both Unicode and MBCS and builds.

#if defined (UNICODE) || defined (_UNICODE)
    typedef wchar_t TCHAR
    #define _T(a) L##a
#else
    typedef char TCHAR
    #define _T(a) a
#endif
#define TEXT(x) _T(x)

This should give you close to, if not the complete set of _T / TEXT macros.

PaulMcKenzie
  • 34,698
  • 4
  • 24
  • 45