C++17 (or more)

Are there any specific instructions on how to use c++17 with oF?
I am following --HEAD and I tried turning OF_USING_STD_FS 1 and changing local my config.make to use c++17.
Nothing compiles. Could someone please tell me what am I missing?

on linux 5.15, using latest gcc

You can use it but it requires some tweaking.
read this discussion about it https://github.com/openframeworks/openFrameworks/issues/6585

Hi Thank you @roymacdonald. I was following instructions from the issue you mentioned.
After the commits by the username “2bbb”, as per instructions just changing the aforementioned macro to 1 should work. But it isnt. So clearly there is a step I am omitting.

Perhaps I will ask there for specific instructions which I can post here in a new thread for others to use

Hey @hypermodernist,

OF_USING_STD_FS is used to enable the standard filesystem extension instead of boost’s. What you want is to change the makefile config for your system.

For gcc on GNU/Linux this line should do the trick.

Edit : I’m on the v0.11.0 and g++ 7.5.

Hey @DarkSalmon
Thank you for your response. So do I not need to change OF_USING_STD_FS for c++17 to work?

I am on gcc 11.1, trying to compile oF from git master. I have tried with both USE_STD_FS with 0 and 1, along with the c++17 setting in makefike common where you suggested. And I cant compile. I could post the errors here if it helps…

Yes it should suffice, I’ve download master to test this out and it worked on my side for what I’ve tried.

(To expands on std::filesystem even if it was scheduled for c+±17 it was still experimental on most implementation last time I checked so I guess that’s why there is an option to use it or not).

edit : (post ahead)

Hey, this was an interesting thread to read. So, I didn’t have any of these issues when using the TBB library with Mint 20.1 (so Ubuntu 20.04), which has gcc 9.3 (I think). Supposedly the TBB library needs c++17, and I added the -std=c++17 flag to the .qbs file in QtCreator. I do have problems compiling on a Mac with the c++17 flag though.

Does anyone have any thoughts as to why I didn’t have these compiler errors on linux?

Edit: Maybe it has something to do with how std::filesystem has evolved between GCC releases, and less to do with c++17?

I followed the instructions on the github issues and now I have it working! I have many libraries that depend on 17, so this is wonderful news.

@TimChi no idea how it worked for you. I had to remove the ifdef at the end of ofFileUtils.h. set compiler flags and then include the fileUtils.h in other places like ofUtils.h, etc… only then it worked for me

1 Like

Hey @hypermodernist thanks so much for posting this! So did you just follow all of the fixes (and only those fixes) that were detailed by themancalledjakob? I (and others) may have to do this too someday, which I’m dreading but I could pull it off if I knew exactly how to do it. Glad you have c++17 working too! So helpful!

@TimChi Yes indeed I just made edits according to the diffs provided by themancalledjakob. Nothing else. And it works just fine. I think they are planning to commit this well before 0.12 release.

To be honest I am already hoping for c++ 20. I have some projects that require passing around member function pointers to different threads through std::function. Very tricky to manage it with locks, specially when parallel processing with the RTAudio Callback thread. Having the std::atomic_ref<Type> variables is the greatest advantage, to be rid of locks and do atomic processing. This is sadly only available in c++20.

I guess it will be years before we see 20 in core

1 Like