compilation

Why does the C++ linker allow undefined functions?

江枫思渺然 提交于 2019-12-02 18:00:15
This C++ code, perhaps surprisingly, prints out 1 . #include <iostream> std::string x(); int main() { std::cout << "x: " << x << std::endl; return 0; } x is a function prototype, which seems to be viewed as a function pointer, and C++ Standard section 4.12 Boolean conversions says: 4.12 Boolean conversions [conv.bool] 1 A prvalue of arithmetic, unscoped enumeration, pointer, or pointer to member type can be converted to a prvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true. For direct-initialization (8

Compiling php with curl, where is curl installed?

。_饼干妹妹 提交于 2019-12-02 17:53:31
I need to specify a directory when compiling php with --with-curl= The curl binary is located at /usr/bin/curl curl -V gives me curl 7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 locate curl gives me /usr/bin/curl /usr/lib/libcurl.so.3 /usr/lib/libcurl.so.3.0.0 /usr/lib64/libcurl.so.3 /usr/lib64/libcurl.so.3.0.0 removed /usr/share/... and other irrelevant files UPDATE Tried --with-curl=/usr/lib64 and --with-curl=/usr/lib although I'm pretty sure it's 64 bit. checking for cURL support... yes checking if we should use cURL for url streams... no checking

The POM for project is missing, no dependency information available

有些话、适合烂在心里 提交于 2019-12-02 17:51:58
Background Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added: mvn install:install-file \ -DgroupId=net.sourceforge.ant4x \ -DartifactId=ant4x \ -Dversion=0.3.0 \ -Dfile=ant4x-0.3.0.jar \ -Dpackaging=jar This created the following directory structure: $HOME/.m2/repository/net/sourceforge/ant4x/ ├── 0.3.0 │ ├── ant4x-0.3.0.jar.lastUpdated │ └── ant4x-0.3.0.pom.lastUpdated └── ant4x ├── 0.3.0 │ ├── ant4x-0.3.0.jar │ ├── ant4x-0.3.0.pom │ └── _remote.repositories └── maven-metadata

Thread.sleep inside infinite while loop in lambda doesn't require 'catch (InterruptedException)' - why not?

≯℡__Kan透↙ 提交于 2019-12-02 17:49:43
My question is about InterruptedException , which is thrown from the Thread.sleep method. While working with ExecutorService I noticed some weird behaviour that I don't understand; here is what I mean: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(() -> { while(true) { //DO SOMETHING Thread.sleep(5000); } }); With this code, the compiler doesn't give me any error or message that InterruptedException from Thread.sleep should be caught. But when I am trying to change the loop condition and replace "true" with some variable like this: ExecutorService executor =

How does code written in one language get called from another language

廉价感情. 提交于 2019-12-02 17:21:18
This is a question that I've always wanted to know the answer, but never really asked. How does code written by one language, particularly an interpreted language, get called by code written by a compiled language. For example, say I'm writing a game in C++ and I outsource some of the AI behavior to be written in Scheme. How does the code written in Scheme get to a point that is usable by the compiled C++ code? How is it used by the C++ source code, and how is it used by the C++ compiled code? Is there a difference in the way it's used? Related How do multiple-languages interact in one project

What is the difference between compilation and interpretation?

霸气de小男生 提交于 2019-12-02 17:18:40
I just had a conversation with a colleague and where were talking about the V8 JavaScript engine. According to Wikipedia, V8 compiles JavaScript to native machine code [...] before executing it, instead of more traditional techniques such as interpreting bytecode or compiling the whole program to machine code and executing it from a filesystem. where (correct me if I'm wrong) " interpreting bytecode " is the way Java works, and " compiling the whole program " would apply for languages like C or C++. Now we were wondering, debating and posing false assertions and presumptions about differences,

Inconsistent behavior of compiler optimization of unused string

别说谁变了你拦得住时间么 提交于 2019-12-02 16:28:22
I am curious why the following piece of code: #include <string> int main() { std::string a = "ABCDEFGHIJKLMNO"; } when compiled with -O3 yields the following code: main: # @main xor eax, eax ret (I perfectly understand that there is no need for the unused a so the compiler can entirely omit it from the generated code) However the following program: #include <string> int main() { std::string a = "ABCDEFGHIJKLMNOP"; // <-- !!! One Extra P } yields: main: # @main push rbx sub rsp, 48 lea rbx, [rsp + 32] mov qword ptr [rsp + 16], rbx mov qword ptr [rsp + 8], 16 lea rdi, [rsp + 16] lea rsi, [rsp +

Understanding STG

纵然是瞬间 提交于 2019-12-02 15:29:36
The design of GHC is based on something called STG, which stands for "spineless, tagless G-machine". Now G-machine is apparently short for "graph reduction machine", which defines how laziness is implemented. Unevaluated thunks are stored as an expression tree, and executing the program involves reducing these down to normal form. (A tree is an acyclic graph, but Haskell's pervasive recursion means that Haskell expressions form general graphs , hence graph-reduction and not tree-reduction.) What is less clear are the terms "spineless" and "tagless". I think that "spineless" refers to the fact

SoftConsole 4.0 “bad instruction” assembler

醉酒当歌 提交于 2019-12-02 15:22:01
问题 Using MicroSemi SoftConsole 4.0 to try to get a FreeRTOS demo project compiled and running, and I've come across an error "bad instruction '[every line of code]'". Basically, the entire file is not being assembled for some reason. My Console looks like this: Building file: ../FreeRTOS-Plus/WolfSSL/wolfcrypt/src/aes_asm.asm Invoking: Cross ARM GNU Assembler arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -O2 -g -x assembler-with-cpp -MMD -MP -MF"FreeRTOS-Plus/WolfSSL/wolfcrypt/src/aes_asm.d" -MT

Why are arrays Objects, but can not be used as a base class?

这一生的挚爱 提交于 2019-12-02 15:21:13
The Java language specification specifies that In the Java programming language arrays are objects (§4.3.1), are dynamically created, and may be assigned to variables of type Object (§4.3.2). All methods of class Object may be invoked on an array. So, considering arrays are objects — why did the Java designers make the decision not to allow inherit and override from it, for example, toString() or equals() ? The current syntax wouldn't allow creating anonymous classes with an array as the base class, but I don't think that was the reason for their decision. Denys Séguret Java was a compromise