10000 Support operator<<(std::ostream& os, ...) custom operators on Windows · Issue #66 · SergiusTheBest/plog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support operator<<(std::ostream& os, ...) custom operators on Windows #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DesktopMan opened this issue Sep 4, 2017 · 9 comments
Closed
Assignees
Milestone

Comments

@DesktopMan
Copy link
DesktopMan commented Sep 4, 2017

Currently it's difficult to use the same code across platforms because Plog expects operator<< to use std::wostream on Windows, while on Linux (and OSX?) you need to use std::ostream. Thus code that builds on Linux fails to build on Windows and the other way around.

If there are other ways to have common operators across platforms I'd love to know.

@SergiusTheBest
Copy link
Owner

Could you provide an example of a problem code?

@SergiusTheBest
Copy link
Owner

Do you mean a custom operator<< ?

@SergiusTheBest SergiusTheBest self-assigned this Sep 4, 2017
@DesktopMan
Copy link
Author
DesktopMan commented Sep 4, 2017

yes, when I provide a custom operator<<.

std::ostream& operator<<(std::ostream& os, const Customer& customer)
{
    os << customer.id << " | " << customer.firstName << " | " << customer.lastName;
    return os;
}

I'm not seeing how I can make this cross platform compatible as the library is now. I tried using wide strings instead but PLOG_ENABLE_WCHAR_INPUT=1 doesn't build on Linux either?

8000

@DesktopMan DesktopMan changed the title [Suggestion] Add a macro to disable wide strings on Windows [Suggestion] Support PLOG_ENABLE_WCHAR_INPUT=0 to disable wide strings on Windows Sep 4, 2017
@SergiusTheBest
Copy link
Owner

I see. I'll take a look what can be done.

@SergiusTheBest
Copy link
Owner

Please, try a version from the ostream-operator-support branch and tell me how it works for you.

@SergiusTheBest
Copy link
Owner

Now plog should use any of std::ostream& operator<< or std::wostream& operator<<.

@DesktopMan
8000 Copy link
Author

I've tested the branch on Windows with MinGW64 6.1.0 and everything works as expected with my existing project using the file logger. Also tested on Linux.

@SergiusTheBest
Copy link
Owner

Excellent.

@DesktopMan DesktopMan changed the title [Suggestion] Support PLOG_ENABLE_WCHAR_INPUT=0 to disable wide strings on Windows Support operator<<(std::ostream& os, ...) custom operators on Windows Sep 6, 2017
@SergiusTheBest SergiusTheBest added this to the 1.1.4 milestone Sep 6, 2017
@SergiusTheBest
Copy link
Owner

Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0