/test/main.cpp:3: error: 'auto' not allowed in function prototype
-
I'm using gcc 9.3.0 and have no issues running this code in Code::Blocks IDE or the CLion IDE.
#include <iostream> void addAndPrint(auto x, auto y) // only valid starting in C++20 { std::cout << x + y << '\n'; } int main() { addAndPrint(2, 3); // int addAndPrint(4.5, 6.7); // double }
But Qt Creator 4.12.0 complains about it,
although the code compiles and runs fine. What exactly's going on here? -
I'm using gcc 9.3.0 and have no issues running this code in Code::Blocks IDE or the CLion IDE.
#include <iostream> void addAndPrint(auto x, auto y) // only valid starting in C++20 { std::cout << x + y << '\n'; } int main() { addAndPrint(2, 3); // int addAndPrint(4.5, 6.7); // double }
But Qt Creator 4.12.0 complains about it,
although the code compiles and runs fine. What exactly's going on here?@Driftwood said in /test/main.cpp:3: error: 'auto' not allowed in function prototype:
But Qt Creator 4.12.0 complains about it....
although the code compiles and runs fine. What exactly's going on here?
The inline warnings/errors are generated by the Clang Code Model (see https://doc.qt.io/qtcreator/creator-clang-codemodel.html ) This model performs live code analysis separately from your compiler.
According to the documentation, the code model currently supports up to C++17. You can disable the model if you wish (see the link for instructions)
-
@Driftwood said in /test/main.cpp:3: error: 'auto' not allowed in function prototype:
But Qt Creator 4.12.0 complains about it....
although the code compiles and runs fine. What exactly's going on here?
The inline warnings/errors are generated by the Clang Code Model (see https://doc.qt.io/qtcreator/creator-clang-codemodel.html ) This model performs live code analysis separately from your compiler.
According to the documentation, the code model currently supports up to C++17. You can disable the model if you wish (see the link for instructions)
-
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
-
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
@Kent-Dorfman said in /test/main.cpp:3: error: 'auto' not allowed in function prototype:
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
Kindly start your wars at a safe distance from this community. Thank you. 😉
-
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
@Kent-Dorfman said in /test/main.cpp:3: error: 'auto' not allowed in function prototype:
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
Time to abandon C++ and just use Python... :(
-
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
@Kent-Dorfman with the probability to start I wildefire, I have to disagree.
It's much more readable/understandable then the template version.
Not necessarily on the OP's case ( for a simple cout) but in general -
@Kent-Dorfman with the probability to start I wildefire, I have to disagree.
It's much more readable/understandable then the template version.
Not necessarily on the OP's case ( for a simple cout) but in general@J-Hilk It's new and it's cool, but it's dangerous, as it encourages implicit type conversions, which are themselves dangerous. I'll stick with templates, and explicitly cast hex on those who disagree. LOL
-
but to risk a flame war, supporting that kind of c++20 function prototyping is an abomination!
@Driftwood said in /test/main.cpp:3: error: 'auto' not allowed in function prototype:
I'm sure C++20 support is right around the corner.
And you're absolutely right!
https://www.qt.io/blog/qt-creator-4.13-released -- "We updated LLVM for the C++ code model to LLVM 10, implicitly improving support for C++20 features."
-
@Driftwood said in /test/main.cpp:3: error: 'auto' not allowed in function prototype:
I'm sure C++20 support is right around the corner.
And you're absolutely right!
https://www.qt.io/blog/qt-creator-4.13-released -- "We updated LLVM for the C++ code model to LLVM 10, implicitly improving support for C++20 features."