Skip to content
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

Compiling error VS2017 #902

Closed
JaNurz opened this issue Nov 11, 2018 · 3 comments
Closed

Compiling error VS2017 #902

JaNurz opened this issue Nov 11, 2018 · 3 comments

Comments

@JaNurz
Copy link

JaNurz commented Nov 11, 2018

Hi! I have just added spdlog to my project and I got those errors:

1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\pattern_formatter.h(1117): error C2589: '(': illegal token on right side of '::'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\pattern_formatter.h(1117): error C2062: type 'unknown-type' unexpected
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\pattern_formatter.h(1160): error C2059: syntax error: '}'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\pattern_formatter.h(1160): error C2143: syntax error: missing ';' before '}'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\sink.h(12): error C2143: syntax error: missing ';' before '{'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\sink.h(12): error C2447: '{': missing function header (old-style formal list?)
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(56): error C2027: use of undefined type 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(51): note: see declaration of 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(56): error C2039: 'set_formatter': is not a member of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(55): note: see declaration of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(357): error C2027: use of undefined type 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(51): note: see declaration of 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(357): error C2039: 'should_log': is not a member of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(55): note: see declaration of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(359): error C2027: use of undefined type 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(51): note: see declaration of 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(359): error C2039: 'log': is not a member of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(55): note: see declaration of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(373): error C2027: use of undefined type 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(51): note: see declaration of 'spdlog::sinks::sink'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\details\logger_impl.h(373): error C2039: 'flush': is not a member of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\common.h(55): note: see declaration of 'std::shared_ptr<spdlog::sinks::sink>'
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\wincolor_sink.h(31): error C2504: 'spdlog::sinks::sink': base class undefined
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\wincolor_sink.h(134): note: see reference to class template instantiation 'spdlog::sinks::wincolor_sink<OutHandle,ConsoleMutex>' being compiled
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\wincolor_sink.h(72): error C3861: 'formatter_': identifier not found
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\wincolor_sink.h(100): error C3861: 'formatter_': identifier not found
1>c:\users\michal\desktop\miengine\dependencies\spdlog-1.x\include\spdlog\sinks\wincolor_sink.h(106): error C3861: 'formatter_': identifier not found

I just added include directory to Additional include directory since cmake have not generated any .lib/dll files.

when I include "spdlog/spdlog.h", those errors show.

Example code included to this library runs fine.

How to fix it?

@JaNurz JaNurz changed the title Compiling error Compiling error VS2017 Nov 11, 2018
@RedshirtMB
Copy link

RedshirtMB commented Nov 11, 2018

The problem is due to the likelyhood your including Windows.h elsewhere in your game engine. One of the headers it uses defines macros for min and max. There are two solutions. The first is to either define NOMINMAX before each include windows.h, or to define it solution-wide ie in your preprocessor definitions. That can lead to trouble though if any libraries you may add depend on the windows.h definitions of min/max.

The second solution, and probably the easiest is just to change the affected line of code ( pattern_formatter.h line 1117) to

return details::padding_info{(std::min)(width, max_width), side};

The additional brackets won't affect the code and they'll defeat the macro re-definition.

@JaNurz
Copy link
Author

JaNurz commented Nov 11, 2018

Thanks!

@JaNurz JaNurz closed this as completed Nov 11, 2018
@gabime
Copy link
Owner

gabime commented Nov 12, 2018

@RedshirtMB and @JaNurz Thanks for spotting the problem.
I think I will replace the call to std::min() with std::min<size_t>(..) to prevent this..

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

No branches or pull requests

3 participants