g++

Compilation of two files from different compiler one is using other

允我心安 提交于 2020-01-16 08:41:42
问题 If I will compile something(x.cpp) with clang++ and generate dynamic link library, let's say x.so files and i will use that .so files in other source(y.cpp) which i am compiling using g++, so do I get any run time error. 来源: https://stackoverflow.com/questions/59623819/compilation-of-two-files-from-different-compiler-one-is-using-other

Does gcc optimize c++ code algebraically and if so to what extent?

让人想犯罪 __ 提交于 2020-01-16 03:32:12
问题 Consider the following piece of code showing some simple arithmetic operations int result = 0; result = c * (a + b) + d * (a + b) + e; To get the result in the expression above the cpu would need to execute two integer multiplications and three integer additions. However algebraically the above expression could be simplified to the code below. result = (c + d) * (a + b) + e The two expressions are algebraically identical however the second expression only contains one multiplication and three

Unexpected exit status when using -pass-exit-codes in g++

这一生的挚爱 提交于 2020-01-16 03:25:48
问题 When doing the following, the exit code of the failed compilation is 1, however, based on this, I would expect it to be >=3. Why is this? What can I do if I want more detailed exit codes than binary success/fail? > echo "int main() {fail}" > fail.cpp > g++ -pass-exit-codes fail.cpp -o fail fail.cpp: In function ‘int main()’: fail.cpp:1: error: ‘fail’ was not declared in this scope fail.cpp:1: error: expected ';' before ‘}’ token > echo $? 1 > g++ --version g++ (GCC) 4.1.3 20080704 (Red Hat 4

Unexpected segfault with __gnu_parallel::accumulate

家住魔仙堡 提交于 2020-01-16 00:51:06
问题 This is really confusing me, I would appreciate if anyone could help me out. (EDIT: thought it was a templated problem, I was mistaken with this) I want to add multiple copies of the following class with gnu's parallelised accumulate algorithm (stored in #include <parallel/numeric> ) The class deliberately doesn't do much, I don't think this is a thread collision problem? template<class T> class NaturalParameters { public: typedef typename std::vector<T>::iterator iterator; NaturalParameters(

undefined reference to 'WinMain' with SDL compiling in a native enviroment

拟墨画扇 提交于 2020-01-16 00:43:12
问题 I'm struggeling with my first steps in SDL. I wanted to compile a simple test class, just including the SDL2 header, nothing special for startup: main.cpp: #include <SDL.h> int main() { return 0; } main.cpp itself compiles fine: g++ -c main.cpp -ISDL/include but as soon as i want to link it with the SDL2.dll either with the machinecode main.o or directly, i'm getting this error: g++ main.cpp -o sdl_test -I SDL/include -L SDL/lib/x64 -l SDL2 -mwindows g++ -o test main.o -L SDL/lib/x64 -l SDL2

How to use `pkg-config gtkmm-3.0 --cflags --libs` in the Visual Studio Code

只谈情不闲聊 提交于 2020-01-15 10:33:56
问题 How can I configure the tasks.json file so that when I press Ctrl + Shift + B the copier will use pkg-config gtkmm-3.0 --cflags --libs . My file looks like this: "version": "0.1.0", "command": "g++ `pkg-config gtkmm-3.0 --cflags --libs`", "isShellCommand": true, "args": ["main.cpp"] But it returns this message: Failed to launch external program g++ pkg-config gtkmm-3.0 --cflags --libs main.cpp. spawn g++ pkg-config gtkmm-3.0 --cflags --libs ENOENT If I put it as an argument, like this:

Linking a Static library into a shared library

。_饼干妹妹 提交于 2020-01-15 06:06:08
问题 I am trying to create a shared library using g++ 5.4.0 on Ubuntu Linux. I have built static libs (.a files) of the Poco C++ library and I want to statically link those into my shared library. But it is not working. I have added the following string to my build script: -Wl,-whole-archive -lPocoFoundation -Wl,-no-whole-archive g++ complains with the following error message: relocation R_X86_64_32S against '-ZTVN4Poco15ArchiveStrategyE' can not be used when making a shared object; recompile with

Linking a Static library into a shared library

微笑、不失礼 提交于 2020-01-15 06:05:34
问题 I am trying to create a shared library using g++ 5.4.0 on Ubuntu Linux. I have built static libs (.a files) of the Poco C++ library and I want to statically link those into my shared library. But it is not working. I have added the following string to my build script: -Wl,-whole-archive -lPocoFoundation -Wl,-no-whole-archive g++ complains with the following error message: relocation R_X86_64_32S against '-ZTVN4Poco15ArchiveStrategyE' can not be used when making a shared object; recompile with

Initializing a class using malloc

本小妞迷上赌 提交于 2020-01-15 05:59:06
问题 I am working on a toy language for avr using C++ as the intermediate language, Problem is avr-gcc does not have new implemented. All my object derive from the class Object which has virtual methods when I create say a float object with malloc using instructions from, Can I implement the Factory Method pattern in C++ without using new? as soon as I cast it to an Object to pass around and back to a Float my program crashes, comments in the answer says that this is due to vtable not initializing

Initializing a class using malloc

匆匆过客 提交于 2020-01-15 05:57:45
问题 I am working on a toy language for avr using C++ as the intermediate language, Problem is avr-gcc does not have new implemented. All my object derive from the class Object which has virtual methods when I create say a float object with malloc using instructions from, Can I implement the Factory Method pattern in C++ without using new? as soon as I cast it to an Object to pass around and back to a Float my program crashes, comments in the answer says that this is due to vtable not initializing