LPCSTR and LPCWSTR template in C: Is it standard?

Started by
1 comment, last by tom_mai78101 13 years, 1 month ago
Here's the code:

Capture-2.png

[color="#008000"]This is a temporary solution to the buggy Code tag. I'm proud of it.

Anyway, as you can see here, I defined a FILENAME macro to either LPCSTR or LPCWSTR, depending on UNICODE if it's defined or not. I mimicked this from any windows.h header files. I am wondering if this is used for passing either LPCSTR or LPCWSTR parameters to a function(s), but since I had compiled this pretty fine, I wouldn't think much about it.

Is this a standard C method?
Advertisement
How about using LPCTSTR (note the T) and include windows.h? Or you can just use UNICODE for all files and not even bother with switching. Just assume you'll always use UNICODE. I imagine the usage of UNICODE or not in windows headers was less about you the programmer being able to compile in both unicode and multi-byte in the same project and more about allowing different projects to pick one or the other.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


How about using LPCTSTR (note the T) and include windows.h? Or you can just use UNICODE for all files and not even bother with switching. Just assume you'll always use UNICODE. I imagine the usage of UNICODE or not in windows headers was less about you the programmer being able to compile in both unicode and multi-byte in the same project and more about allowing different projects to pick one or the other.


Oh thanks for the reminder.

Note to Self: LPTSTR is UNICODE-wise (Configurable) type. LPCTSTR is UNICODE-wise (selectable) constant type.

This topic is closed to new replies.

Advertisement