g++

Generated code not matching expectations with Extended ASM

老子叫甜甜 提交于 2019-12-11 11:15:00
问题 I have a CpuFeatures class. The requirements for the class are simple: (1) preserve EBX or RBX , and (2) record the values returned from CPUID in EAX/EBX/ECX/EDX . I'm not sure the code being generated is the code I intended. The CpuFeatures class code uses GCC Extended ASM. Here's the relevant code: struct CPUIDinfo { word32 EAX; word32 EBX; word32 ECX; word32 EDX; }; bool CpuId(word32 func, word32 subfunc, CPUIDinfo& info) { uintptr_t scratch; __asm__ __volatile__ ( ".att_syntax \n" #if

extern const linkage specification being seemingly ignored by G++

偶尔善良 提交于 2019-12-11 11:08:27
问题 I have a situation building a C codebase with a C++ compiler that parallels this: lib.h extern int const values[2] = {1, 2}; lib.c #include "lib.h" main.c #include <iostream> extern int const values[2]; int main() { std::cout << values[0] << ":" << values[1] << std::endl; } I had to add the extern because of something pointed out in the C++03 Standard Annex C Compatibility C.1.2 Clause 3. (Compiling with -fpermissive will sweep this under the rug.) Incidentally the difference it makes in how

Not possible to compile. Headers files.Enclosed own objects definition

瘦欲@ 提交于 2019-12-11 11:05:28
问题 Here I am with a similar question as the last time, and for which I could not find any answer. Note that I consider important: Normally I compile my programs in opencv with the next command: g++ -o def program.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv` This line will create an executable whose name will be def and that I will be able to use. I am working in a project, and as it was getting bigger, I had to define some objects, just to make everything easier and possible to

How to compile a libtorrent(rasterbar) code ?

孤街醉人 提交于 2019-12-11 10:59:09
问题 I want to compile example (make_torrent) from libtorrent official website: g++ create_torrent_file.cpp -o run -lboost_filesystem-mt But I get this error: create_torrent_file.cpp:(.text+0x158): undefined reference to `libtorrent::file_storage::file_storage()' I have libtorrent-rasterbar installed ldconfig -v | grep libtorrent: libtorrent-rasterbar.so.6 -> libtorrent-rasterbar.so.6.0.0 So how should I compile this source code? 回答1: You need to add libtorrent-rasterbar to the linker. Try the

Why std::size() is not a member of std in gcc 8.2.0

穿精又带淫゛_ 提交于 2019-12-11 10:42:46
问题 I'm trying to teach myself some C++17. Why is the compiler throwing an error for the below code snippet? #include <iostream> #include <vector> #include <iterator> int main() { std::vector<int> v = { 3, 1, 4 }; std::cout << std::size(v) << '\n'; int a[] = { -5, 10, 15 }; std::cout << std::size(a) << '\n'; } The compiler throws the following error manish@Manish-Tummala:~/c_files$ g++ 6.cpp -o - 6.out 6.cpp: In function ‘int main()’: 6.cpp:8:23: error: ‘size’ is not a member of ‘std’ std::cout <

Is it possible to build boost with clang and gcc support?

那年仲夏 提交于 2019-12-11 10:35:10
问题 I am running into an odd problem, where I need to access boost libraries using both gcc and clang specific modules (these programs interact. One is gcc/g++ exclusive, and one is clang exclusive). Is there any way to build boost so that both modules access the same location when calling boost, but boost is able to facilitate gcc or clang specific requests? 回答1: It is possible, but it's questionable if you really should do that. You would have to choose either to use libc++ or libstdc++ with

C++ linker error when trying to build from object files made using makefile. Does not occur when I just build it

∥☆過路亽.° 提交于 2019-12-11 10:06:07
问题 I'm trying to make a makefile for a multi-file C++ project that builds object files, then builds my application from those object files. It works without any errors when I use the command: all: src/main.cpp src/main_funcs.cpp src/menu.cpp src/logging.cpp\ src/runonce.cpp src/wordify.cpp src/vte.cpp g++ -Wall `pkg-config --cflags gtk+-3.0, vte-2.91, glib-2.0, gio-2.0`\ -std=c++14 -o "updater" src/main.cpp src/main_funcs.cpp \ src/logging.cpp src/menu.cpp src/runonce.cpp \ src/wordify.cpp src

Problem in C++ class with static variables and functions

余生长醉 提交于 2019-12-11 09:49:40
问题 Can someone tell me what is problem in the following class, g++ is giving errors on ubuntu: class FibonacciGenerator { private: static int num1, num2, counting; public: static void Reset() { num1 = 0; num2 = 1; counting = 1; } static int GetCount() { return counting; } static int GetNext() { int val = 0; if(counting == 1) val = num1; else if(counting == 2) val = num2; else { val = num1 + num2; num1 = num2; num2 = val; } counting ++; return val; } }; 回答1: The statement static int num1, num2,

In the code::blocks compiler for linux, how can one add compilation flags like '-lrt' or '-lboost_thread'?

若如初见. 提交于 2019-12-11 09:28:57
问题 Debugging in gdb is not convenient for me so I enjoy the nice debugging interface that code::blocks offers. Now that I have moved my project into an area where those flags are required (the ones in the title, of course), I find that I can't compile on code::blocks anymore :/. 回答1: Hi everyone I figured out how to add the -lrt. Since -lrt is passed to the linker and not the compiler you can go to Settings->Compiler and Debugger->linker options then press add and after doing a "locate lrt" I

Undefined reference errors when including Rcpp.h

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 09:23:19
问题 I am using 64bit Ubuntu, and I am trying to write C++. I discovered if I use #include <Rcpp.h> , I don't even need to call any functions in the R namespace, and I would already receive undefired reference errors: obj/x.o: In function `Rcpp::Rstreambuf<true>::xsputn(char const*, long)': /usr/local/lib/R/site-library/Rcpp/include/Rcpp/iostream/Rstreambuf.h:61: undefined reference to `Rprintf' obj/x.o: In function `Rcpp::Rstreambuf<false>::xsputn(char const*, long)': /usr/local/lib/R/site