Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <wchar.h>
  3. #include <errno.h>
  4.  
  5. typedef wchar_t WCHAR;
  6. typedef const wchar_t * PCWCH;
  7. #define WIDEN2(x) L ## x
  8. #define WIDEN(x) WIDEN2(x)
  9. #ifdef _WIN32
  10. #define __WFUNCTION__ WIDEN(__FUNCTION__) L"(): "
  11. #elif __linux__
  12. #define MAX_FUNC_NAME_SIZE 1024
  13. WCHAR func_name[MAX_FUNC_NAME_SIZE];
  14. #define __WFUNCTION__
  15. (AsciiStrToUnicodeStr(__FUNCTION__, func_name, MAX_FUNC_NAME_SIZE) == 0) ? func_name : L"(): "
  16. #endif
  17.  
  18.  
  19. int AsciiStrToUnicodeStr(const char *src, WCHAR *destination, unsigned int dest_max)
  20. {
  21. size_t retval;
  22. if (!src || !destination || (dest_max == 0)) {
  23. return -EINVAL;
  24. }
  25. retval = mbstowcs(destination, src, dest_max);
  26. return (retval == -1) ? retval : 0;
  27. }
  28.  
  29. void DbgTrace(PCWCH pwcFormat,...)
  30. {
  31.  
  32. wprintf(L"%lsn", pwcFormat);
  33.  
  34. }
  35.  
  36. void test()
  37. {
  38.  
  39. DbgTrace(__WFUNCTION__ L"ERROR: Null string passedrn");
  40. }
  41.  
  42. int main()
  43. {
  44. DbgTrace(__WFUNCTION__ L"ERROR: Null string passedrn");
  45. test();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement