Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <wchar.h>
- #include <errno.h>
- typedef wchar_t WCHAR;
- typedef const wchar_t * PCWCH;
- #define WIDEN2(x) L ## x
- #define WIDEN(x) WIDEN2(x)
- #ifdef _WIN32
- #define __WFUNCTION__ WIDEN(__FUNCTION__) L"(): "
- #elif __linux__
- #define MAX_FUNC_NAME_SIZE 1024
- WCHAR func_name[MAX_FUNC_NAME_SIZE];
- #define __WFUNCTION__
- (AsciiStrToUnicodeStr(__FUNCTION__, func_name, MAX_FUNC_NAME_SIZE) == 0) ? func_name : L"(): "
- #endif
- int AsciiStrToUnicodeStr(const char *src, WCHAR *destination, unsigned int dest_max)
- {
- size_t retval;
- if (!src || !destination || (dest_max == 0)) {
- return -EINVAL;
- }
- retval = mbstowcs(destination, src, dest_max);
- return (retval == -1) ? retval : 0;
- }
- void DbgTrace(PCWCH pwcFormat,...)
- {
- wprintf(L"%lsn", pwcFormat);
- }
- void test()
- {
- DbgTrace(__WFUNCTION__ L"ERROR: Null string passedrn");
- }
- int main()
- {
- DbgTrace(__WFUNCTION__ L"ERROR: Null string passedrn");
- test();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement