Installed clang 14.0 using GNU/Guix's clang-toolchain package.
I am getting depreciated feature usage error when
trying to compile a simple code:
//build with: clang++ main.cpp
//main.cpp
#include <iostream>
int main() {
std::cout << "hello world!" << std::endl;
}
The error message is:
[Guix profile dir]/include/c++/backward/binders.h:130:6: error: expected ';' after class
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
The error happens regardless of which STL header
the code includes. For example, it fails when <string>
is included with the same error message.
Any idea how to resolve the error?
Update 1:
This seems to be a configuration error. It goes away if the compilation is done inside a Guix container environment:
guix environment --container clang-toolchain -- clang++ main.cpp -o main
Update 2:
[This turned out to be WRONG. It is related to lack of multilib support in gcc-toolchain]
The error still persists when running the same code in a Guix environment with the --pure option. This means the
error isn't due to environment setting.
There is also an older bug report addressing the same issue: https://bugzilla.redhat.com/show_bug.cgi?id=1896076. The
error message in the bug can be reproduced when running
the test code using emscripten:
emcc -o main.html main.cpp
The problem is the bug was already addressed in Fedora 33?
I am currently on: Linux/fedora 5.17.4-200.fc35.x86_64 with
a Guix environment: guix describe --format=channels:
(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(branch "master")
(commit
"59b91fdbcd7e1a88d1d54d392ce5d5fddd9d96d1")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))
(channel
(name 'flat)
(url "https://github.com/flatwhatson/guix-channel.git")
(branch "master")
(commit
"f43c67e47f1ca83d045f35c31772c5e4eb64b2a2")
(introduction
(make-channel-introduction
"33f86a4b48205c0dc19d7c036c85393f0766f806"
(openpgp-fingerprint
"736A C00E 1254 378B A982 7AF6 9DBE 8265 81B6 4490")))))
Update 3: It seems the latest clang-toolchain#14.0.0 breaks when installed alongside gcc-toolchain#11.2.0. That is, in the same Guix profile. Downgrading gcc-toolchain to version 10.3.0 resolved the error.
The issue can be reproduced with:
guix shell clang-toolchain#14.0.0 gcc-toolchain#11.2.0 --container -- clang++ main.cpp
Output:
In file included from main.cpp:1:
In file included from /gnu/store/../profile/include/c++/iostream:39:
In file included from /gnu/store/../profile/include/c++/ostream:38:
In file included from /gnu/store/../profile/include/c++/ios:42:
In file included from /gnu/store/../profile/include/c++/bits/ios_base.h:41:
In file included from /gnu/store/../profile/include/c++/bits/locale_classes.h:40:
In file included from /gnu/store/../profile/include/c++/string:48:
In file included from /gnu/store/../profile/include/c++/bits/stl_function.h:1407:
/gnu/store/../profile/include/c++/backward/binders.h:130:6: error: expected ';' after class
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
^
/gnu/store/../profile/include/c++/backward/binders.h:130:7: error: C++ requires a type specifier for all declarations
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
^
/gnu/store/../profile/include/c++/backward/binders.h:165:6: error: expected ';' after class
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
^
/gnu/store/../profile/include/c++/backward/binders.h:165:7: error: C++ requires a type specifier for all declarations
} _GLIBCXX11_DEPRECATED_SUGGEST("std::bind");
Downgrading gcc to gcc-toolchain#10.3:
guix shell clang-toolchain#14.0.0 gcc-toolchain#10.3.0 --container -- clang++ main.cpp
Output:
Expected file(a.out) is produced
Related
I am trying oneAPI from Intel office website: https://www.intel.com/content/www/us/en/develop/documentation/oneapi-programming-guide/top/programming-interface/example-compilation.html
I have completed step 1 “oneAPI Development Environment Setup” and verified it successfully.
In step 2, when I run dpcpp -I${MKLROOT}/include -c axpy.cpp -o axpy.o, it reports several errors:
oneapi/compiler/2022.0.1/linux/bin-llvm/../include/sycl/CL/sycl/bit_cast.hpp:33:22: error: no member named 'is_trivially_copyable' in namespace 'std'
oneapi/compiler/2022.0.1/linux/bin-llvm/../include/sycl/CL/sycl/sycl_span.hpp:164:42: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'detail::remove_cv_t'
oneapi/compiler/2022.0.1/linux/bin-llvm/../include/sycl/CL/sycl/sycl_span.hpp:187:39: error: no template named 'is_array_v' in namespace 'std'; did you mean 'is_array'
I guess there is some compatibility issue, but I have no idea how to fix.
Thanks!
The issue might be with the version of GCC that you have in your system, please check in the system requirements for DPCPP compiler from the below link, intel.com/content/www/us/en/developer/articles/… "Supported minimum versions of distributed libraries that the compilers are built on: GCC - 7.3.0, BINUTILS- 2.30, GLIBC-2.27"
I am trying to a C++ library and need (want) to use nested namespaces in order to increase readability of the code. However, I am running into a problem when trying to compile my code in the Windows Command Prompt with g++ main.c.
The code below is an example of what I will have -- a nested namespace and then some functions or classes:
namespace gpc::warning {
void raiseError() {
std::cout << "Error...\n";
exit(1);
}
}
The code below is an example for my main.c file:
#include <iostream>
#include "Warning/raise.hpp"
int main() {
std::cout << "Hello, World!" << std::endl;
gpc::warning::raiseError();
return 0;
}
When I run this simple probram in CLion, it compiles and runs perfectly, however when I run the code in the Windows 10 Command Prompt, I get the following error telling me something about the namespaces:
In file included from main.cpp:2:0:
Warning/raise.hpp:10:14: error: expected '{' before '::' token
namespace gpc::warning {
^
Warning/raise.hpp:10:16: error: 'warning' in namespace '::' does not name a type
namespace gpc::warning {
^
main.cpp: In function 'int gpc::main()':
main.cpp:9:10: error: 'gpc::warning' has not been declared
gpc::warning::raiseError();
^
main.cpp: At global scope:
main.cpp:12:1: error: expected '}' at end of input
}
^
I was wondering what I am doing wrong and how I can fix this problem.
Thanks!
Try updating your g++ version to 6.1.0 or higher.
The code doesn't compiles on g++ v5.5.0 even with -std=gnu++17 flag. You can check that here. (Reason: Nested namespaces weren't supported by the compiler then.)
The code shall compile with compiler defaults (without any flags) on g++ v6.1.0 or higher. You can check this here.
You can check your compiler version by running: g++ --version on cmd.
Pro Tip: Locate your CLion's compiler and if it is g++ then add that one to path. (No need of wasting internet data on updating the old g++ compiler!)
This is probably the weirdest thing I have seen in the last few years.
I have a project that builds perfectly well in two completely different machines (openSUSE Tumbleweed and ubuntu 14.04).
I started with a new machine using kubuntu 16.04 and this error started happening:
$ g++ -std=c++14 cout_qualif.cpp -lpng -o cout_qualif
In file included from cout_qualif.cpp:1:0:
debug_utils.h:19:19: error: invalid use of ‘::’
# define msg std::cout
Clang also points an error, but with a quite different message:
$ clang -std=c++14 cout_qualif.cpp -lpng -o cout_qualif
In file included from cout_qualif.cpp:3:
In file included from /usr/include/png++/png.hpp:34:
In file included from /usr/include/png.h:317:
/usr/include/zlib.h:94:19: error: non-friend class member 'cout' cannot have a qualified name
z_const char *msg; /* last error message, NULL if no error */
^~~
./debug_utils.h:19:19: note: expanded from macro 'msg'
# define msg std::cout
~~~~~^
1 error generated.
The simplest test code I've came across is:
#include <iostream>
#include "debug_utils.h"
#include <png++/png.hpp>
int main()
{
msg << "Start" << std::endl;
png::image< png::rgb_pixel > image("input.png");
image.write("output.png");
msg << "Finish" << std::endl;
return 0;
}
And "debug_utils.h":
#ifndef DEBUG_UTILS_H
#define DEBUG_UTILS_H
#include <iostream>
# define msg std::cout
#endif // DEBUG_UTILS_H
It turns out that "png.h" includes "zlib.h" and there is defined a struct:
typedef struct z_stream_s {
// ...
z_const char *msg; /* last error message, NULL if no error */
This msg member is what is triggering the error. If I move my #include "debug_utils.h" one line below, after #include <png++/png.hpp>, everything seems to work fine.
Now finally the question:
Why this machine cannot compile my code while two other can?
Additional info:
Kubuntu 16.04:
$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
$ clang --version
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
openSUSE Tumbleweed:
g++ is 7.1.1
Ubuntu 14.04:
Exact version not available at hand but I believe it is 4.9.x
To recap the cause of the problem
# define msg std::cout
in debug_utils.h substitutes std::cout for any instances of msg throughout the code after debug_utils.h is included. As msg is a common short identifier, particularly for a message buffer, an unintended substitution has always been a risk lurking in the code. The solution to this is obvious: Don't do that. Use a longer, less likely to be duplicated substitution or don't do it at all and replace the macro. Without seeing your usecase I'd probably replace the macro with a function that returns the correct stream and the compiler can easily inline.
The confusion and the question stems from why an error from the macro substitution only arises from a simple piece of test code when compiled on only one of three candidate PCs.
The answer is differences in the toolchain and support libraries. For one reason or another, on only one of these PCs a third-party header that uses the msg identifier is included by a third-party header included by the test program. The other two follow different inclusion paths to build the same program and avoid tripping over the unwanted substitution.
In my environment, I couldn't include <cstring>.
My g++ version is 4.9.3 (Homebrew gcc49 4.9.3).
The error is:
- /usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cstring:42:20: fatal
error: string.h: No such file or directory
"#include string.h"
But, in another environment (g++ 4.8.4[Ubuntu 4.8.4-2ubuntu1~14.04.3]), I can include <cstring> and run.
What's the problem and how do I solve it?
[P.S.]
Maybe, I misunderstood about the problem.
I tried to run my previous code, but got an error like this:
/usr/local/Cellar/gcc49/4.9.3/include/c++/4.9.3/cassert:43:20: fatal error: assert.h: No such file or directory
#include <assert.h>
Then, I can't run my code.
It is a g++'s problem.
I checked this article, but this procedure is not working.
I already installed xcode-select (commmad line tool) and I uninstalled xcode-select and reinstalled xcode-select, but it's not working.
Building C++ not working in OSX 10.9
Reinstalling the heaaders fixed my issue:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
I am using NS2.35 and Ubuntu 12.04.5 LTS
I want to run DSR using link cache.
I uesd "make" to recompile NS2. I got the following error:
dsr/linkcache .cc: fatal error: list.h: no such file or directory.
I used locate list.h and this is its directory
/usr/src/linux-headers-3.2.0-29/include/linux/list.h
That means the header file exists
How can I solve this error ?
ns2 : Old files. The gcc 2.95 header list.h is included in a couple of files. And is simply ignored in a stock ns2, when g++ is later than version 3.x :
list.h is also present in gcc 3.2, 3.3, 3.4 : /usr/include/c++/3.4.6/backward/list.h
Besides that, a similar question is answered here make command not working in NS 2.35