Microsoft Specific —>
As the table of generic-text routine mappings indicates (see Appendix B, Generic-Text Mappings), when the manifest constant _MBCS is defined, a given generic-text routine maps to one of the following kinds of routines:
Following are three solutions for preventing this type conflict (and the C compiler warnings or C++ compiler errors that would result):
char *_tcsrev(char *);
In the default case, the prototype for _tcsrev maps to _mbsrev through a thunk in LIBC.LIB. This changes the types of the _mbsrev incoming parameters and outgoing return value from _TCHAR * (i.e., char *) to unsigned char *. This method ensures type matching when you are using _TCHAR, but it is relatively slow because of the function call overhead.
#define _USE_INLINING
This method causes an inline function thunk, provided in TCHAR.H, to map the generic-text routine directly to the appropriate MBCS routine. The following code excerpt from TCHAR.H provides an example of how this is done.
__inline char *_tcsrev(char *_s1)
{return (char *)_mbsrev((unsigned char *)_s1);}
If you can use inlining, this is the best solution, because it guarantees type matching and has no additional time cost.
#define _MB_MAP_DIRECT
This approach provides a fast alternative if you do not want to use the default behavior or cannot use inlining. It causes the generic-text routine to be mapped by a macro directly to the MBCS version of the routine, as in the following example from TCHAR.H.
#define _tcschr _mbschr
When you take this approach, you must be careful to ensure that appropriate data types are used for string arguments and string return values. You can use type casting to ensure proper type matching or you can use the _TXCHAR generic-text data type. _TXCHAR maps to type char in SBCS code but maps to type unsigned char in MBCS code. For more information about generic-text macros, see Appendix B, Generic-Text Mappings.
END Microsoft Specific