[FR] Emit warning when discontinued macro still defined

In this commit, the JUCE_STANDALONE_APPLICATION macro has been discontinued, meaning that if a project #defines it to whatever value, it is no longer relevant for the JUCE codebase.

My request is that JUCE emits a compilation warning when it finds that such a discontinued macro is still defined.

I can see several cases in which that has a direct positive impact on client code. For example:

  • If client code just #defined the macro to configure JUCE, but didn’t use it directly, then it can remove its definition resulting in tidier code.
  • If client code also used the macro internally, the warning can give the developer an heads up on how to remove the dependency from the macro in his code as well, for example replacing it with a runtime call (as it is the case with JUCE_STANDALONE_APPLICATION)

This has been requested some other times on the forum, not just by me, when JucePlugin_AUHighResolutionParameters, JUCE_COREGRAPHICS_DRAW_ASYNC, and a couple other macros I can’t remember have been phased out.

The code to do that is almost already in place: consider that before removal of JUCE_STANDALONE_APPLICATION, there was this bit of code in juce_core.cpp:

 JUCE_COMPILER_WARNING ("Please re-save your project with the latest Projucer version to avoid this warning")

Instead of removing it, it would be enough to replace it with:

// notice the change from ifndef to ifdef
 JUCE_COMPILER_WARNING ("JUCE_STANDALONE_APPLICATION no longer has effect for JUCE. If you are using it in your code, please use isStandaloneApp() instead.")

p.s. Even if some of these definitions are meant to be handled by Projucer or CMAKE, and re-saving/exporting the project should automatically remove them, please keep in mind that there are JUCE projects out there that are not actively managed with either tool.
Several projects may have been started as “bootstrapped” with Projucer years ago, but re-opening them and resaving with it is a no-go because of the several customizations that they underwent in the mean time.

This is such a good idea and got my vote. I haven’t yet actually upgraded my plugins to JUCE 7 so I haven’t really bothered scrutinising the changes from JUCE 6 in this regard, but it’s something I seem to remember from a cursory glance at them that there are some defines that were removed in the transition, so this kind of warning would be fantastic.