1

I'm trying to integrate logging into my Windows C++ application, and I wanted to use Pantheios, as it generally has very favorable comments. That said, all the examples included are using macros like PANTHEIOS_LITERAL_STRING etc., for wrapping string literals, and require typedefs like:

typedef std::basic_string<PAN_CHAR_T> string_t;

to compile correctly. I think this is ugly, and would prefer to not use these typedefs.

Here's an example: http://www.pantheios.org/doc/html/cpp_2misc_2example_8cpp_8misc_8strings_2example_8cpp_8misc_8strings_8cpp-example.html

I tried compiling Pantheios with PANTHEIOS_USE_WIDE_STRINGS disabled but get lots of build errors -- any ideas?

Mike Hornblade
  • 1,544
  • 2
  • 14
  • 19
  • What was the question? How to build with or without wide char support? What exact error message your encounter? – Sergei Nikulov Jun 20 '11 at 23:15
  • I'm basically asking if I'm crazy -- does everyone just use this library with wide strings? I went ahead with widestring support, but it's painful if you're logging them to files, as every character is two bytes. so wordpad shows log messages like: – Mike Hornblade Jun 20 '11 at 23:22
  • t h i s i s y o u r l o g – Mike Hornblade Jun 20 '11 at 23:23
  • ..\..\src\util\time.cpp(299) : error C2440: 'initializing' : cannot convert from 'int (__stdcall *)(LCID,DWORD,const SYSTEMTIME *,const stlsoft::winstl_project: :ws_char_a_t *,stlsoft::winstl_project::ws_char_a_t *,int)' to 'int (__stdcall *)(LCID,DWORD,const SYSTEMTIME *,LPCTSTR,LPTSTR,int)' – Mike Hornblade Jun 20 '11 at 23:28
  • ^^^^ this is a sample error when I disable wide character support and do a full build. – Mike Hornblade Jun 20 '11 at 23:45
  • 1
    I'm not using wide strings. Your example from notepad normal for multibyte character representation. Use any unicode-aware editor to see it as you expected. And I don't remember that it required to define something to turn it off. Just change your VS solution to use multibyte character-encoding to char — instead of default widestring character-encoding wchar_t. It should be somewhere in solution explorer->Properties->General->C/C++. – Sergei Nikulov Jun 21 '11 at 00:08
  • 1
    Or just don't use "Unicode" targets. – Sergei Nikulov Jun 21 '11 at 00:31
  • FYI: the setting is Character Set, and it's located in Configuration Properties->General. Select "Use Multi-Byte Character Set" if you don't need/want to use wide string facilities – dcw Jun 21 '11 at 01:34

1 Answers1

1

As you've observed the file backend assumes multibyte output in a multibyte build, and wide output in a wide build by default, but IIRC there are initialisation options (for be.file) that allow you to force it one way or the other, regardless of how you're building.

fwiw, I would think that the examples have to take into account all permutations, and that's why the "ugliness" you report is there. If you're only building for one char encoding or the other, you don't have to do that. Pretty much like examples of Windows coding that use TCHAR and all the _tcsXXX() funcs: you don't have to do that unless you're wanting your code to work with both.

HTH

dcw
  • 3,481
  • 2
  • 22
  • 30