Solved filesystem in C++17 and Q_OBJECT conflicts
-
@jronald
what compiler (version) are you using? -
@jronald said in filesystem in C++17 and Q_OBJECT conflicts:
But <std> doesn't exist.
I didn't say it did, I was talking conceptually. In any case since you know
#include <QApplication> #include <filesystem>
works, use that. Else you'll have to follow the discussion in that stackoverflow post.
-
Hi,
I use filesystem from stdlib without trouble. And without using QApplication in same file.
I suspect that errormessage from first post depends on files included before "filesystem" (not mentioned in your post).
The given line from error message looks like:
namespace std _GLIBCXX_VISIBILITY(default)
So may be 'namespace' has been declared as a macro or that GLib-Token does not exists. I can't imagine of other errors.
The include-file "std" (without extension) is a boost include file.
so may be, something is mixed without intention?
-
@raven-worx said in filesystem in C++17 and Q_OBJECT conflicts:
@jronald
what compiler (version) are you using?g++ 11.1.0
-
@django-Reinhard said in filesystem in C++17 and Q_OBJECT conflicts:
Hi,
I use filesystem from stdlib without trouble. And without using QApplication in same file.
I suspect that errormessage from first post depends on files included before "filesystem" (not mentioned in your post).
The given line from error message looks like:
namespace std _GLIBCXX_VISIBILITY(default)
So may be 'namespace' has been declared as a macro or that GLib-Token does not exists. I can't imagine of other errors.
The include-file "std" (without extension) is a boost include file.
so may be, something is mixed without intention?
To reproduce the problem, two conditions must be meeted:
#include <filesystem>
before#include <QApplication>
MyApp
must inlcudeQ_OBJECT
-
@jronald
You can keep asking questions and have others make guesses if you wish, but I have already given you the stackoverflow post which shows this error and indicates where the problem lies (i.e. in the toolchain).As it states there, the error comes from
moc
. And that is only invoked if you have aQ_OBJECT
macro present. It also tells you the problem lies in cmake (which is what you are using), but not in qmake. Hence your findings.I'll leave you to it now.
-
This is a bug in MOC: https://bugreports.qt.io/browse/QTBUG-73263 what they suggest is to reorder the includes as you already figured out
-
@jronald
Hi, Here is something else: there is no <filesystem> file on my installation? How do I get this?Regards
Frik Brits. -
@britsfp What compiler do you have?
You need C++17 capable compiler and also C++17 needs to be activated in pro file when using g++/MinGW (CONFIG += c++17). -
@jsulm I am using Qt 6.2.1. In the Kits's Compile tab It has gcc 7 and gcc 10 for C programs.
For C++ compiler it has g++ 7 and g++ 10I could always change the soft link in /usr/bin ??
-
@britsfp said in filesystem in C++17 and Q_OBJECT conflicts:
I could always change the soft link in /usr/bin ??
There is no need for such hacks.
Simply define the compiler in your Kit in QtCreator. -
@jsulm
Ok So must both C and C++ be version 10?, I supose so ? - and what is this #include <filesystem> error I get from the qfile.h header? -
@britsfp C doesn't matter most of the time, unless you want to compile C code.
But usually should point to same compiler version."and what is this #include <filesystem> error I get from the qfile.h header?" - as I said already: you need a compiler which supports C++17 standard and you need to enable this standard in your pro file.
https://en.cppreference.com/w/cpp/filesystem -
@britsfp g++ 7 does not support <filesystem>. If you can, set both C and C++ to 11 which supports C++20
-