Skip to content

Some clarification on wide vs narrow string on linux #302

@vpopescu

Description

@vpopescu

HI, I'm probably missing something, but...

I am trying to use plog in a program that targets both windows and linux. Windows build is fine so far, and if I understand correctly, it uses these settings:

#define PLOG_ENABLE_WCHAR_INPUT 1 
#define PLOG_CHAR_IS_UTF8 0

When I try to use these in linux, I am having issues with the file access functions being narrowchar for linux, e.g. in Utils:

size_t open(const nstring& fileName)
            {
#if defined(_WIN32) && (defined(__BORLANDC__) || defined(__MINGW32__))
                m_file = ::_wsopen(toWide(fileName).c_str(), _O_CREAT | _O_WRONLY | _O_BINARY | _O_NOINHERIT, SH_DENYWR, _S_IREAD | _S_IWRITE);
#elif defined(_WIN32)
                ::_wsopen_s(&m_file, toWide(fileName).c_str(), _O_CREAT | _O_WRONLY | _O_BINARY | _O_NOINHERIT, _SH_DENYWR, _S_IREAD | _S_IWRITE);
#elif defined(O_CLOEXEC)
                m_file = ::open(fileName.c_str(), O_CREAT | O_APPEND | O_WRONLY | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#else
                m_file = ::open(fileName.c_str(), O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
#endif
                return seek(0, SEEK_END);
            }

however nstring was already defined as wchar_t due to the defines above. Do i need to keep linux using narrowstring?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions