diff --git a/HISTORY.rst b/HISTORY.rst index 5dbb1ba7..4481d4d6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -33,6 +33,7 @@ PlatformIO 4.0 * **Miscellaneous** - Deprecated ``--only-check`` PlatformIO Core CLI option for "update" sub-commands, please use ``--dry-run`` instead + - Fixed an issue when ``-U`` in ``build_flags`` does not remove macro previously defined via ``-D`` flag (`issue #2508 `_) PlatformIO 3.0 -------------- diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 3a0347c4..2d1fc0fd 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -198,6 +198,8 @@ def ProcessFlags(env, flags): # pylint: disable=too-many-branches if undefines: for undef in undefines: env['CCFLAGS'].remove(undef) + if undef[2:] in env['CPPDEFINES']: + env['CPPDEFINES'].remove(undef[2:]) env.Append(_CPPDEFFLAGS=" %s" % " ".join(undefines))