compilation

How to test that some code doesn't compile in C++? [duplicate]

守給你的承諾、 提交于 2020-01-13 10:54:07
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Unit test compile-time error I'm wondering if its possible to write a kind of unit test which will verify that a given code doesn't compile. For example, I have a template class: #include <boost/static_assert.hpp> #include <boost/type_traits/is_base_of.hpp> struct bar_base {}; template <typename T> class foo { BOOST_STATIC_ASSERT(::boost::is_base_of<T, bar_base>::value); }; So, the test should succeed with:

php module does not compile. Does not recognize “static function_entry”

为君一笑 提交于 2020-01-13 08:03:49
问题 I have recently recompiled my php and suddenly old code (together with examples from the internet) stopped compiling. This exact example does not compile. Snippet of the problematic code: static function_entry hello_functions[] = { {NULL, NULL, NULL} }; This is the error: /home/user/php_module/test_module/hello.c:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘hello_functions’ What could be the problem? 回答1: Solution : It's the difference for new php 5.4 Found the answer

How to compile a C code during execution time, and get a pointer to the corresponding function?

可紊 提交于 2020-01-13 07:21:12
问题 Suppose I generate a C program during execution time: source = "int add_x_y(int x, int y){ return x + y; }"; source_size = 42; I want the following function: void* compile(char* source, int source_size); Such that: int (*f)(int,int) = compile(source, source_size); printf("%d\n",f(2,3)); Outputs: 5 And compile can't depend on external tools (compilers), as I'd like to use it in emscripten (which converts a C program to a .js file). Is that possible? 回答1: Someone else can probably fill in some

How would a DOM-less,statically typed, ahead-of-time-compiled javascript code compare to native code performance-wise?

放肆的年华 提交于 2020-01-13 03:59:10
问题 The traditional answer to "why is Javascript slower than native code?" is: "Because it's interpreted". The problem with this claim is that interpretation is not a quality of the language itself. As a matter of fact, nowadays most Javascript code is being JITed, still, this isn't even close to native speed. What if we remove the interpretation factor from the equation and make Javascript AOT compiled? Will it then match the performance of native code? If yes, why isn't this widely done over

Undefined reference gcc

家住魔仙堡 提交于 2020-01-13 02:42:12
问题 When I try to compile my program on ubuntu using gcc, i get these errors: main.c:(.text+0x162): undefined reference to json_parse' main.c:(.text+0x182): undefined reference to json_value_free' However, these functions are included in a file called json.h, which I import in main.c and which I include in my gcc command. Anyone got a clue? 回答1: You should not compile the "json.h" header. The undefined reference is not a compiler error, it's a linker error . It means you have either not compiled

Undefined reference gcc

家住魔仙堡 提交于 2020-01-13 02:42:07
问题 When I try to compile my program on ubuntu using gcc, i get these errors: main.c:(.text+0x162): undefined reference to json_parse' main.c:(.text+0x182): undefined reference to json_value_free' However, these functions are included in a file called json.h, which I import in main.c and which I include in my gcc command. Anyone got a clue? 回答1: You should not compile the "json.h" header. The undefined reference is not a compiler error, it's a linker error . It means you have either not compiled

When are JavaScript regular expression literals compiled

随声附和 提交于 2020-01-13 02:31:12
问题 According to MDN's RegExp Guide regular expression literals are compiled while RegExp objects created by calling the constructor are not. My question is now, when does the compilation take place? As the literal has unique syntax it is identified as a regular expression during parsing. This would make it possible to compile it once and reuse the result every time it gets evaluated resulting in the two examples having (almost) the same speed. var str = "Hello World"; // Example 1 var regExp1 =

When are JavaScript regular expression literals compiled

家住魔仙堡 提交于 2020-01-13 02:31:02
问题 According to MDN's RegExp Guide regular expression literals are compiled while RegExp objects created by calling the constructor are not. My question is now, when does the compilation take place? As the literal has unique syntax it is identified as a regular expression during parsing. This would make it possible to compile it once and reuse the result every time it gets evaluated resulting in the two examples having (almost) the same speed. var str = "Hello World"; // Example 1 var regExp1 =

Problem compiling in Clojure

旧街凉风 提交于 2020-01-12 18:45:54
问题 I've been trying to compile a very simple test.clj in Clojure without any success. I have a thread on the Clojure Google Group with several responses, but nothing has helped. To quickly summarize, here is my clojure file: (ns test.test (:gen-class)) (defn -main [gre] (println (str "Hello " gre))) Basically it's the example file provided in the Clojure documentation. I have placed this file appropiately in clojure/src/test/test.clj , and should be able to compile with (compile 'test.test) ,

Fix “Ignoring InnerClasses attribute” warning

被刻印的时光 ゝ 提交于 2020-01-12 18:28:50
问题 I would like to fix this warning that give me each build this output: Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(com.sun.jna.Native$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type