Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1785
Closed
Open
Issue created Aug 03, 2022 by Daniel Berlin@dberlin

Much easier fix for min vs std::min issue

(It's not obvious where the website docs live in github, or i'd just submit a pull request) The troubleshooter for the std::min vs arduino min macro (https://arduinojson.org/v6/troubleshooter/?utm_source=github&utm_medium=readme#compiletime/macro-min/success) says to disable std::string/std::stream support.

Just to flag there is actually a much easier fix that does not require compiler flags and should work everywhere.

Before including ArduinoJson.h, do this:

#include <Arduino.h>
#undef min

min is guaranteed to be defined in C++ so we don't have to worry that we will remove the only definition (it's also supposed to be an inline function and not a macro, which is why it conflicts in the first place)

Including the header ourselves guarantees that all the macros are defined and that the header won't be reincluded by someone else. #undef min then removes the conflicting macro definition. This will work:

  1. On all systems where someone uses ArduinoJSON
  2. whether the min macro exists or not.
  3. without removing support for std::*

Figured i would flag this.

Assignee
Assign to
Time tracking