openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

How to Disable Both OF_LEGACY_INCLUDE_STD and OF_USE_MINIMAL_STD

Open 2bbb opened this issue 10 months ago • 2 comments

I believe that OF_USE_MINIMAL_STD is a best-effort way to maintain compatibility. However, I think it would be good to provide a method to disable it entirely as well.

For example, like the following:

#ifndef OF_DISABLE_INCLUDE_STD
    #ifdef OF_LEGACY_INCLUDE_STD
using namespace std;
    #else

// this will eventually be disabled by default
        #define OF_USE_MINIMAL_STD
        #ifdef OF_USE_MINIMAL_STD
using std::cout;
using std::deque;
using std::endl;
using std::make_shared;
using std::map;
using std::max;
using std::pair;
using std::shared_ptr;
using std::string;
using std::stringstream;
using std::swap;
using std::to_string;
using std::vector;
using std::weak_ptr;
        #endif // OF_USE_MINIMAL_STD
    #endif // OF_LEGACY_INCLUDE_STD
#endif // ifndef OF_DISABLE_INCLUDE_STD

This is a method that ignores both using statements by defining OF_DISABLE_INCLUDE_STD. Is there a better approach?

2bbb avatar Mar 01 '25 07:03 2bbb

@2bbb yes this was a compromise to immediately get the bad byte and other conflicts out of the way, while providing a "manual" access point for updating core with no using. the idea is to make these opt-in, so the temporary line #define OF_USE_MINIMAL_STD will be removed after the next release (12.1), then the conditionals will make more sense.

artificiel avatar Mar 01 '25 16:03 artificiel

I like your approach and I vote so it can be made to 0.12.1

It can be moved (maybe) to projects later, handled by projectGenerator.

I've been writing ofGen (alternative to PG) that works from a recipe, so we can have a configuration like this:

defines:
  - NANOVG_GL2_IMPLEMENTATION

so it reflects in different templates as

config.make

PROJECT_DEFINES = NANOVG_GL2_IMPLEMENTATION

xcode / Project.xcconfig

 GCC_PREPROCESSOR_DEFINITIONS=$(inherited) NANOVG_GL2_IMPLEMENTATION

etc

dimitre avatar Mar 01 '25 18:03 dimitre