clang

Proper way to include C code from directories other than the current directory

核能气质少年 提交于 2020-01-05 05:37:13
问题 I have two directories, sorting and searching (children of the same directory), that have .c source files and .h header files: mbp:c $ ls sorting array_tools.c bubble_sort.c insertion_sort.c main selection_sort.c array_tools.h bubble_sort.h insertion_sort.h main.c selection_sort.h mbp:c $ ls searching array_tools.c array_tools.h binary_search.c binary_search.h linear_search.c linear_search.h main main.c Within searching , I am building an executable that needs to use insertion_sort function,

How to profile code in hexagon dsp simulator

狂风中的少年 提交于 2020-01-05 04:23:08
问题 I have been trying to compile my code using -pg to enable profiling in the simulator and once I do that it gives me linker errors. Compilation command hexagon-clang++ main.cpp -o hello -mv62 -pg Error hexagon-clang++ main.cpp -o hello -mv62 -pg Error: /tmp/main-924ac3.o(.text+0x30): undefined reference to `mcount' Error: /tmp/main-924ac3.o(.text+0x130): undefined reference to `mcount' Fatal: Linking had errors. This is my first time to write code for DSP chip, specifically the hexagon 682.

.gcda files don't merge on multiple runs

眉间皱痕 提交于 2020-01-05 04:21:31
问题 I have two main functions that use a common C++ class. File1: main.cpp #include <iostream> #include "HelloAnother.h" int main() { HelloAnother::sayHello1(); return 0; } File2: main2.cpp #include <iostream> #include "HelloAnother.h" int main() { HelloAnother::sayHello2(); return 0; } File3: HelloAnother.h #pragma once class HelloAnother { public: static void sayHello1(); static void sayHello2(); }; File4: HelloAnother.cpp #include <iostream> #include "HelloAnother.h" void HelloAnother:

Is a configuration of clang QtC 4.7 checks per config file possible?

不想你离开。 提交于 2020-01-05 04:19:13
问题 QtC 4.7 offers the inline CLANG code checks, as shown in the screenshots. I can configure those from options/C++ . But I wonder if I can have a config file which I can commit (git) so everyone in the team is using the same checks. Is that possible (e.g. similar to Artistic style where I can use a file or the config in QtC)? The checks I mean: Configure in C++ options, can I do the same in a config file? --- Edit --- I could use the annotations like [[clang::fallthrough]] which silence the

Can't link libFuzzer.a using clang with libc++

喜欢而已 提交于 2020-01-05 04:03:12
问题 I'm trying to link together: libFuzzer.a, compiled with clang++-5.0 and -std=c++11 my fuzz driver, compiled with clang++-5.0 and -std=c++11 -stdlib=libc++ libcurl, compiled with clang-5.0 Specifically, this linker command is being executed: /bin/bash ../../libtool --silent --tag=CXX --mode=link clang++-5.0 -I../../include -I../../lib -I../../lib -I../../tests/fuzz -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp -std=c++11 -stdlib=libc++ -o

Lvalue to rvalue conversion not performed

落爺英雄遲暮 提交于 2020-01-04 06:01:27
问题 The following function returns an rvalue: int foo() { int x = 42; return x; // x is converted to prvalue } Clang's AST also shows the conversion: `-FunctionDecl <line:1:1, line:5:1> line:1:5 foo 'int ()' `-CompoundStmt <line:2:1, line:5:1> |-DeclStmt <line:3:5, col:15> | `-VarDecl <col:5, col:13> col:9 used x 'int' cinit | `-IntegerLiteral <col:13> 'int' 42 `-ReturnStmt <line:4:5, col:12> `-ImplicitCastExpr <col:12> 'int' <LValueToRValue> ^^^^^^^^^^^^^^ `-DeclRefExpr <col:12> 'int' lvalue Var

Lvalue to rvalue conversion not performed

☆樱花仙子☆ 提交于 2020-01-04 06:01:04
问题 The following function returns an rvalue: int foo() { int x = 42; return x; // x is converted to prvalue } Clang's AST also shows the conversion: `-FunctionDecl <line:1:1, line:5:1> line:1:5 foo 'int ()' `-CompoundStmt <line:2:1, line:5:1> |-DeclStmt <line:3:5, col:15> | `-VarDecl <col:5, col:13> col:9 used x 'int' cinit | `-IntegerLiteral <col:13> 'int' 42 `-ReturnStmt <line:4:5, col:12> `-ImplicitCastExpr <col:12> 'int' <LValueToRValue> ^^^^^^^^^^^^^^ `-DeclRefExpr <col:12> 'int' lvalue Var

Object cannot be assigned because its copy assignment operator is implicitly deleted error

杀马特。学长 韩版系。学妹 提交于 2020-01-04 05:41:06
问题 In my small arkanoid clone game I'm trying to erase some values from a vector. This vector contains Brick classes, that are instantiated on the screen in a grid like pattern. When a collision happens between the ball and a brick, the brick needs to disappear. I'm trying to accomplish this with this small piece of code: for (int i = 0; i < bricks.size(); ++i) { if (bricks[i].destroyed) { bricks.erase(bricks.begin()+i); } } But unfortunately I get this compile error: Object of type 'Brick'

Command parameters for b2 in order to build Boost libraries with Microsoft's Clang/C2

落爺英雄遲暮 提交于 2020-01-04 04:56:46
问题 I have been trying to compile Boost libraries using b2 in Windows but using Clang/C2 (Clang 3.7 with Microsoft CodeGen), to no success. Since Visual Studio comes with several toolsets to use at build time, it seems it shouldn't be too hard to specify which. I have seen another posting relating to "building boost with clang 3.8 on windows" but his proposal to use as command line for b2 is in error because it is not really invoking the clang compiler from MSVC. The person posting that used the

C: why does LLVM evaluate printf left-to-right when GCC evaluates right-to-left?

霸气de小男生 提交于 2020-01-04 04:06:25
问题 As stated in this question: LLVM and GCC, different output same code, LLVM and GCC result in different output for the same code. #include <stdio.h> #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) int increment() { static int i = 42; i += 5; printf("increment returns %d\n",i); return i; } int main( int argc, char ** argv ) { int x = 50; printf("max of %d and %d is %d\n", x,increment(),MAX(x, increment())); printf("max of %d and %d is %d\n", x,increment(),MAX(x, increment())); return 0; } The LLVM