Skip to content

Commit

Permalink
Fix build failed on Windows
Browse files Browse the repository at this point in the history
reason:
- std::min & std::max got mistmatched with Win32's min max macros
- __PRETTY_FUNCTION__ is not supported by MSVC, even if its pretty..
  • Loading branch information
baderouaich committed Oct 2, 2023
1 parent f54967a commit f731b58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions include/tgbotxx/objects/Object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ namespace nl = nlohmann;
field = json[json_field].get<T>(); \
} catch(const std::exception& e) { \
std::ostringstream err{}; \
err << __FILE__ << ':' << __LINE__ <<": "<<__PRETTY_FUNCTION__<<": Failed to deserialize \"" \
err << __FILE__ << ':' << __LINE__ <<": "<<__FUNCTION__<<": Failed to deserialize \"" \
<< json_field << "\" from json object: " << json.dump(2) << "\nReason: " << e.what(); \
throw Exception(err.str()); \
} catch(...) { \
std::ostringstream err{}; \
err << __FILE__ << ':' << __LINE__ <<": "<<__PRETTY_FUNCTION__<<": Failed to deserialize \"" \
err << __FILE__ << ':' << __LINE__ <<": "<<__FUNCTION__<<": Failed to deserialize \"" \
<< json_field << "\" from json object: " << json.dump(2); \
throw Exception(err.str()); \
} \
Expand All @@ -60,7 +60,7 @@ namespace nl = nlohmann;
if(not (optional)) \
{ \
std::ostringstream err{}; \
err << __FILE__ << ':' << __LINE__ <<": "<<__PRETTY_FUNCTION__<<": Missing required field \"" \
err << __FILE__ << ':' << __LINE__ <<": "<<__FUNCTION__<<": Missing required field \"" \
<< json_field << "\" from json object: " << json.dump(2); \
throw Exception(err.str()); \
} \
Expand All @@ -79,7 +79,7 @@ namespace nl = nlohmann;
if(not (optional)) \
{ \
std::ostringstream err{}; \
err << __FILE__ << ':' << __LINE__ <<": "<<__PRETTY_FUNCTION__<<": Missing required field \"" \
err << __FILE__ << ':' << __LINE__ <<": "<<__FUNCTION__<<": Missing required field \"" \
<< json_field << "\" from json object: " << json.dump(2); \
throw Exception(err.str()); \
} \
Expand All @@ -101,7 +101,7 @@ namespace nl = nlohmann;
if(not (optional)) \
{ \
std::ostringstream err{}; \
err << __FILE__ << ':' << __LINE__ <<": "<<__PRETTY_FUNCTION__<<": Missing required field \"" \
err << __FILE__ << ':' << __LINE__ <<": "<<__FUNCTION__<<": Missing required field \"" \
<< json_field << "\" from json object: " << json.dump(2); \
throw Exception(err.str()); \
} \
Expand Down Expand Up @@ -131,7 +131,7 @@ namespace nl = nlohmann;
if(not (optional)) \
{ \
std::ostringstream err{}; \
err << __FILE__ << ':' << __LINE__ <<": "<<__PRETTY_FUNCTION__<<": Missing required field \"" \
err << __FILE__ << ':' << __LINE__ <<": "<<__FUNCTION__<<": Missing required field \"" \
<< json_field << "\" from json object: " << json.dump(2); \
throw Exception(err.str()); \
} \
Expand Down
2 changes: 1 addition & 1 deletion src/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::vector<Ptr<Update>> Api::getUpdates(std::int32_t offset, std::int32_t limit
const std::vector<std::string> &allowedUpdates) const {
cpr::Multipart data = {
{"offset", offset},
{"limit", std::max(1, std::min(100, limit))},
{"limit", (std::max)(1, (std::min)(100, limit))},
{"timeout", timeout},
{"allowed_updates", allowedUpdates.empty() ? "[]" : nl::json{allowedUpdates}.dump()},
};
Expand Down
2 changes: 1 addition & 1 deletion src/Bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void Bot::dispatchMessage(const Ptr<Message> &message) {
} else if (atSymbolPosition == std::string::npos) {
splitPosition = spacePosition;
} else {
splitPosition = std::min(spacePosition, atSymbolPosition);
splitPosition = (std::min)(spacePosition, atSymbolPosition);
}
std::string command = message->text.substr(1, splitPosition - 1);
std::vector<Ptr<BotCommand>> myCommands = m_api->getMyCommands();
Expand Down

0 comments on commit f731b58

Please sign in to comment.