g++

Create a C wrapper around a C++ library that can be linked by a C linker

五迷三道 提交于 2019-12-21 19:56:18
问题 Following the answer given to this question (Developing C wrapper API for Object-Oriented C++ code) I managed to write a C wrapper for my C++ code. I would like to compile and link my wrapper into a static library (compiled using g++) that could be used, compiled and linked using gcc only (not g++). This way the user of the library would not have to care that the library is written in C++. Is this something possible? 回答1: This link explains some of the compiler options and scenarios: http:/

gcc 4.5 installation problem under ubuntu

匆匆过客 提交于 2019-12-21 18:07:58
问题 I tried to install gcc 4.5 on ubuntu 10.04 but failed. Here is a compile error that I don't know how to solve. Is there anyone successfully install the latest gcc on ubuntu? Following is my steps and the error message, I'd like to know where is the problem.... Step1: download these files: gcc-core-4.5.0.tar.gz gcc-g++-4.5.0.tar.gz gmp-4.3.2.tar.bz2 mpc-0.8.1.tar.gz mpfr-2.4.2.tar.gz Step2: Unzip above files Step3: move gmp, mpc, mpfr to the gcc-4.5.0/ directory. mv gmp-4.3.2 gcc-4.5.0/gmp mv

Detecting underflow during execution

喜你入骨 提交于 2019-12-21 16:04:31
问题 Is there any way to detect underflow automatically during execution? Specifically I believe there should be a compiler option to generate code that checks for underflows and similar falgs right after mathematical operations that could cause them. I'm talking about the G++ compiler. 回答1: C99/C++11 have floating point control functions (e.g. fetestexcept ) and defined flags (including FE_UNDERFLOW ) that should let you detect floating point underflow reasonably portably (i.e., with any compiler

mtune and march when compiling in a docker image

烈酒焚心 提交于 2019-12-21 12:22:52
问题 When compiling in a docker image (i.e. in the dockerfile), what should march and mtune be set to? Note this is not about compiling in a running container, but compiling when the container is being built (e.g. building tools from source when the image is run). For example, currently when I run docker build and install R packages from source I get loads of (could be g++/gcc/f95 ...): g++ -std=gnu++14 [...] -O3 -march=native -mtune=native -fPIC [...] If I use native in an image built by

clang++ fails but g++ succeeds on using a cast to const-unrelated-type operator in an assignment

≡放荡痞女 提交于 2019-12-21 09:21:42
问题 Here's a short example that reproduces this “no viable conversion” with lemon for clang but valid for g++ difference in compiler behavior. #include <iostream> struct A { int i; }; #ifndef UNSCREW_CLANG using cast_type = const A; #else using cast_type = A; #endif struct B { operator cast_type () const { return A{i}; } int i; }; int main () { A a{0}; B b{1}; #ifndef CLANG_WORKAROUND a = b; #else a = b.operator cast_type (); #endif std::cout << a.i << std::endl; return EXIT_SUCCESS; } live at

How to get rid of g++ hash_map deprecation warning?

不羁岁月 提交于 2019-12-21 09:19:22
问题 When I compile a c++ application I'm writing that makes use of hash_map, I get this warning on g++ 4.3.2: You are using the deprecated header . To eliminate this warning, use an ANSI-standard header file or use hte -Wno-deprecated compiler flag. 9> #include <ext/hash_map> What include replaces this? I've searched for a while on google, and can't find anything except for people having similar problems, but no solution. 回答1: My very first Google hit for "g++ hash_map deprecated" takes me to a

error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ - pthreads

笑着哭i 提交于 2019-12-21 09:17:17
问题 anisha@linux-y3pi:~> g++ conditionVarTEST.cpp -Wall conditionVarTEST.cpp: In function ‘int main()’: conditionVarTEST.cpp:33:53: error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ conditionVarTEST.cpp:33:53: error: initializing argument 3 of ‘int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)’ conditionVarTEST.cpp:34:53: error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ conditionVarTEST.cpp:34:53: error: initializing argument 3 of ‘int pthread

C++11: g++-4.7 internal compiler error

╄→гoц情女王★ 提交于 2019-12-21 09:06:49
问题 The following code: #include <iostream> #include <array> using namespace std; constexpr int N = 1000000; constexpr int f(int x) { return x*2; } typedef array<int, N> A; template<int... i> struct F { static constexpr A f() { return A{{ ::f(i)... }}; } }; template<class A, class B> struct C {}; template<int... i, int... j> struct C<F<i...>, F<j...>> : F<i..., (sizeof...(i)+j)...> { using T = F<i..., (sizeof...(i)+j)...>; }; template<int n> struct S : C<typename S<n/2>::T, typename S<n-n/2>::T>

std::common_type implementation

僤鯓⒐⒋嵵緔 提交于 2019-12-21 08:05:08
问题 Just to see how it worked, I looked at the libstdc++ implementation of std::common_type in the header type_traits . I have to admit that I don't really understand how it works. Here it is: /// common_type template<typename... _Tp> struct common_type; template<typename _Tp> struct common_type<_Tp> { typedef _Tp type; }; template<typename _Tp, typename _Up> struct common_type<_Tp, _Up> { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; }; template<typename _Tp, typename _Up,

std::common_type implementation

空扰寡人 提交于 2019-12-21 08:02:30
问题 Just to see how it worked, I looked at the libstdc++ implementation of std::common_type in the header type_traits . I have to admit that I don't really understand how it works. Here it is: /// common_type template<typename... _Tp> struct common_type; template<typename _Tp> struct common_type<_Tp> { typedef _Tp type; }; template<typename _Tp, typename _Up> struct common_type<_Tp, _Up> { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; }; template<typename _Tp, typename _Up,