compilation

How does an interpreter run code?

江枫思渺然 提交于 2021-01-27 12:06:38
问题 Reading all the compiled vs interpreted articles it seems like compiled means the machine will run the compiled code directly whereas interpreted, the interpreter will run the code. But how does the interpreter run the code if it's on a machine? Doesn't it still end up having to convert what it's interpreting into machine code and STILL having the machine run it? At the end of the day, everything has to end up being machine code in order for the machine to run it right? It seems like

Cross Compiling for Raspi - Executing the programm ends in “Segmentation fault”

流过昼夜 提交于 2021-01-27 09:37:59
问题 I have a self-written programm which I want to build also for Raspberry Pi from my x86 machine. I'm using eclipse generated makefiles and cannot change this thing. I've read this tutorial for CC for raspi : Hackaday-Link. Because raspi also have installed gcc version 4.9, I also try it with this version of the cross compiler. The problem also exisits with this hello world programm: #include <iostream> using namespace std; int main(int argc, char *argv[]) { cout << "hello world!" << endl; }

Cross Compiling for Raspi - Executing the programm ends in “Segmentation fault”

﹥>﹥吖頭↗ 提交于 2021-01-27 09:35:54
问题 I have a self-written programm which I want to build also for Raspberry Pi from my x86 machine. I'm using eclipse generated makefiles and cannot change this thing. I've read this tutorial for CC for raspi : Hackaday-Link. Because raspi also have installed gcc version 4.9, I also try it with this version of the cross compiler. The problem also exisits with this hello world programm: #include <iostream> using namespace std; int main(int argc, char *argv[]) { cout << "hello world!" << endl; }

why we must recompile a c source code for a different os on the same machine?

送分小仙女□ 提交于 2021-01-27 05:32:13
问题 When I compile my c source code (for example in a Linux environment) the compiler generates a file in a "machine readable" format. Why the same file is not working on the same machine under a different operating system? Is the problem about the way we "execute" this file? 回答1: Sometimes it will work, depending on the format and the libraries that you use, etc.. For example, things like allocating memory or creating a window all call the OS functions. So you have to compile for the target OS,

Do compilers optimize out net zero bit shifts?

允我心安 提交于 2021-01-27 04:12:37
问题 I have some code like the following code block (I am not allowed to post the original code) inside a .cpp file that I think is being compiled by clang++ ( Ubuntu clang version 3.5.2-3ubuntu1 (tags/RELEASE_352/final) (based on LLVM 3.5.2) ). It looks like C code, because we are using GoogleTest for testing our C code. Anyways: size_t const SHIFT = 4; uint8_t var, var2; /* Omitted: Code that sets var to, say 00011000 (base 2) */ var2 = var; var = var << SHIFT >> SHIFT; // [1] result is 00011000

Do compilers optimize out net zero bit shifts?

主宰稳场 提交于 2021-01-27 04:11:11
问题 I have some code like the following code block (I am not allowed to post the original code) inside a .cpp file that I think is being compiled by clang++ ( Ubuntu clang version 3.5.2-3ubuntu1 (tags/RELEASE_352/final) (based on LLVM 3.5.2) ). It looks like C code, because we are using GoogleTest for testing our C code. Anyways: size_t const SHIFT = 4; uint8_t var, var2; /* Omitted: Code that sets var to, say 00011000 (base 2) */ var2 = var; var = var << SHIFT >> SHIFT; // [1] result is 00011000

Unnecessarily replacing a task that does not exist is not supported

安稳与你 提交于 2021-01-26 03:45:30
问题 I got the following error: FAILURE: Build failed with an exception. * Where: Initialization script 'C:\Users\User\AppData\Local\Temp\Console_main__.gradle' line: 18 * What went wrong: A problem occurred configuring root project 'demo'. > Could not create task ':Console.main()'. > Unnecessarily replacing a task that does not exist is not supported. Use create() or register() directly instead. You attempted to replace a task named 'Console.main()', but there is no existing task with that name.

Accessing tokenization of a C++ source file

纵饮孤独 提交于 2021-01-25 23:04:09
问题 My understanding is that one step of the compilation of a program (irrespective of the language, I guess) is parsing the source file into some kind of space separated tokens (this tokenization would be made by what's referred to as scanner in this answer. For instance I understand that at some point in the compilation process, a line containing x += fun(nullptr); is separated is something like x += fun ( nullptr ) ; Is this true? If so, is there a way to have access to this tokenization of a

Accessing tokenization of a C++ source file

浪子不回头ぞ 提交于 2021-01-25 23:02:49
问题 My understanding is that one step of the compilation of a program (irrespective of the language, I guess) is parsing the source file into some kind of space separated tokens (this tokenization would be made by what's referred to as scanner in this answer. For instance I understand that at some point in the compilation process, a line containing x += fun(nullptr); is separated is something like x += fun ( nullptr ) ; Is this true? If so, is there a way to have access to this tokenization of a

How can I find out the date of when my source code was compiled?

喜夏-厌秋 提交于 2021-01-23 00:39:23
问题 Is it possible to store and display the date of when my project was compiled? I'd like to print this date when the program starts in order to know which version is used. Currently, I am doing this by hand, which is rather cumbersome. I am using Visual Studio 2010. 回答1: You can use the __DATE__ and __TIME__ macros - see "Predefined macros" here. As a sample, something like this: #include <iostream> int main() { using namespace std; cout << "Compiled on: " << __DATE__ << endl; cout << "Compiled