Menu
  • HOME
  • TAGS

clang/clang++ doesn't find C/C++ headers in windows?

c++,c,clang,llvm,mingw-w64

Try this one Installing Clang 3.5 for Windows. Regards....

getting error mno-fused-madd installing kivy in virtualenv over fish shell

xcode5,clang,llvm,osx-mavericks,kivy

This is caused by an apparent bug in cython 0.22, which we haven't resolved in kivy master yet (it's not clear what's best, or whether we should fix part of the problem in cython itself). You can resolve it by using cython 0.21, or alternatively there's a pull request for...

Same FLT_EVAL_METHOD, different results in GCC/Clang

c,gcc,floating-point,clang

This answer is about something that you should resolve before you go further, because it is going to make reasoning about what happens much harder otherwise: Surely printing “0.1 = 0x0.07fff00000001p-1022” or “0.1 = 0x0.0000000000001p-1022” can only be a bug on your compilation platform caused by ABI mismatch when using...

QuickBlox: error !! Not able to run app in device after framework update

ios,objective-c,clang,linker-error,quickblox

Try to update Xcode to latest 6.3 - this should work

How to clone or create an AST Stmt node of clang?

clang,llvm

Creating new AST nodes is quite cumbersome in Clang, and it's not the recommended way to use libTooling. Rather, you should "read" the AST and emit back code, or code changes (rewritings, replacements, etc). See this article and other articles (and code samples) linked from it for more information on...

Expanded from macro 'num' while printing it using printf by Clang compiler

c,gcc,macros,clang,c-preprocessor

It is probably complaining that the expression expanded from color_num is an unsigned (perhaps unsigned long) while the format in the printf is a signed integer. sizeof gives size_t, which is always an unsigned type, as noted in is size_t always unsigned?, but the number of bits depends on the...

Can constexpr be combined with volatile?

c++,c++11,gcc,clang,language-lawyer

Yes, this is valid, there was defect report 1688: Volatile constexpr variables that was filed for this, saying: There does not appear to be language in the current wording stating that constexpr cannot be applied to a variable of volatile-qualified type. Also, the wording in 5.19 [expr.const] paragraph 2 referring...

c++11 thread pool works on windows - blocks on linux

linux,windows,multithreading,c++11,clang

You are violating the standard's requirements for calling wait: void wait(unique_lock& lock); Requires: lock.owns_lock() is true and lock.mutex() is locked by the calling thread, and either: — no other thread is waiting on this condition_variable object or — lock.mutex() returns the same value for each of the lock arguments supplied...

How can I parse a C format string in Python?

python,c,regex,clang,pycparser

You can certainly find properly formatted candidates with a regex. Take a look at the definition of the C Format Specification. (Using Microsofts, but use what you want.) It is: %[flags] [width] [.precision] [{h | l | ll | w | I | I32 | I64}] type You also have...

How to set compiler-specific flags with autotools

gcc,clang,autotools,compiler-options

AM_CXXFLAGS isn't something you should AC_SUBST. It is reserved for use by automake. If you look at the Makefile generated for a C++ target, you will find definitions for CXXCOMPILE and LTCXXCOMPILE, which always include the AM_CXXFLAGS variable. You want to add the (conditional) compiler flag to AM_CXXFLAGS or to...

Is free() zeroing out memory?

c,gcc,memory-management,clang,free

There's no single definitive answer to your question. Firstly, the external behavior of a freed block will depend on whether it was released to the system or stored as a free block in the internal memory pool of the process or C runtime library. In modern OSes the memory "returned...

ThreadSanitizer (tsan) - Meaningful information from shared library

c++,multithreading,clang,wxwidgets,thread-sanitizer

The issue is that FreeBSD 10.1 and before has a bug, preventing llvm-symbolizer from working correctly. llvm-symbolizer is how TSAN gets the symbol information. More specifically, FreeBSD gives a dlpi_name without the path in dl_iterate_phdr. This was patched at https://reviews.freebsd.org/D932. The patch is available in FreeBSD 10-STABLE (at the time...

How to change compilation flags for MyFramework_vers.c in Xcode?

objective-c,xcode,linker,clang

I don't know of a way to modify the compiler arguments for this file, but it's possible to address the warning by abusing VERSION_INFO_EXPORT_DECL. Set the value to a literal newline followed by #import "HeaderWithExternDeclarations.h" and another literal newline. In the pbxproj it should look something like this: VERSION_INFO_EXPORT_DECL =...

gcc doesn't accept pack expansion in default template argument

c++,c++11,gcc,clang

You haven't violated any rule. It appears to be a problem with GCC's support for variable templates, not only default arguments, because this adjustment works: template <typename ... T> struct f { static constexpr bool v = false; }; template <typename ... Ts, bool F = fn::call(f<Ts>::v ...)> void hoge...

How to build LLVM doxygen in HTML ? I tried but failed

clang,llvm,doxygen

I collect the web-site by wget.

Is this code valid or not? GCC and Clang disagree

c++11,gcc,clang,initializer-list

Using GCC 4.9.1 and the following options: -Wall -Wextra -std=c++11 -pedantic this is what you get: prog.cc:7:5: warning: ISO C++ prohibits anonymous structs [-Wpedantic] }; ^ prog.cc: In constructor 'Bar::Bar()': prog.cc:11:21: warning: ISO C++ does not allow C99 designated initializers [-Wpedantic] Bar(void) : test{.a = 1, .b = 2} {...

clang/llvm ARM instrinics

clang,llvm,intrinsics

If you are planning on getting into ARM asm, I would really suggest that you just skip any use of intrinsics. It seems like a nice idea, just mix your C and asm. But, in actual practice it will save you time and many headaches by just writing a whole...

Fixing error duplicate symbol _response in: …: linker command failed with exit code 1 (use -v to see invocation)

ios,objective-c,xcode,clang

The Service and County files both seem to have a response symbol. Maybe the old project had a preprocessor symbol that excluded one, or maybe both files weren't actually compiled in the target.

clang 3.6 fold expression left/right

c++,clang,clang++,c++1z

n4191 was revised by n4295. According to that, an expression of the form (e op ...) is a unary right fold, and that is expanded as: E1 op (... op (EN-1 op EN)), i.e. as a right fold expansion. This does seem to be the reverse of what n4191 stated...

LLVM: intermediate bytecode vs binary

clang,llvm

LLVM is a framework for manipulating LLVM IR (the "bytecode" you're alluding to) and lowering it to target-specific binaries (for example x86 machine code). Clang is a front-end for C/C++ (and Objective C) that translates these source languages into LLVM IR. With this in mind, answering your questions: For all...

clang+llvm provides a bad function pointers for JIT compiled functions

c++,clang,llvm,jit

This assignment is incredibly messed up: *(int **) (&funcPtr) = *(int **) fPtr; Not only does it violate strict-aliasing to write an int* and then use it as a function pointer on the next line, but a data pointer is often not large enough to hold an entire code pointer....

Clang (3.6.0) ignores warnings from included header files

c++,clang,clang++

This is not clang bug, the warning is being suppressed because x is subsequently unused, the bug report I cite below explains the rationale behind this behavior. In this specific case it is considered a clang feature to not to produce this warning(Wuninitialized) if the variable is otherwise unused, although...

How to increment a Global Variable in a LLVM module?

c++,clang,llvm

Yes, you'll have to create load, add, and store instructions. In LLVM's C++ class hierarchy, Instruction subclasses Value. When you create your LoadInst, you can just refer to it directly when creating new instructions. For example: IRBuilder<> IR(SomeInsertionPoint); LoadInst *Load = IR.CreateLoad(MyGlobalVariable); Value *Inc = IR.CreateAdd(IR.getInt32(1), Load); StoreInst *Store =...

Clang Pragma Comprehensive List

xcode,clang,llvm

You're doing everything right, the only thing you're missing is: Clang we have in Xcode is different from Clang we can download at http://clang.llvm.org. You can obtain Apple's version of compiler at http://opensource.apple.com under 'Developer tools', but usually there is pretty old version. Whenever Apple engineers introduce something new into...

std::bad_function_call when calling std::swap in visual studio

c++,visual-studio,gcc,clang

Introduction The reason for the behavior is quite simple; m_deleter is unconditionally invoked in the destructor of Foo, even in circumstances when it isn't callable. The straight forward implementation of std::swap creates a temporary to hold the intermediate result of one of the two operands, this temporary will not have...

Installing twitcurl on OS X

c++,osx,twitter,makefile,clang

I can get the shared / dynamic library to compile but needed to make a couple of adjustments to your Makefile: LDFLAGS += -rpath $(STAGING_DIR)/usr/lib and $(CC) -dynamiclib -shared -Wl,-install_name,lib$(LIBNAME).dylib.1 $(LDFLAGS) -o lib$(LIBNAME).dylib *.o -L$(LIBRARY_DIR) -lcurl I've now also built the associated twitterClient utility. To do so, I had to...

Is there a way to use GCC __attribute__((noreturn)) and sanely in a single translation unit?

c,gcc,clang,c11

Use __attribute__((__noreturn__)), instead. All the gcc attributes have a __ version such that you can sanely use them in system headers without polluting the user name space. Some platform providers also don't seem to be aware of that problem. I recently discovered that for OS X they have the unprotected...

Use protected static function of the base class from the friend of the derived class

c++,clang

This is CWG issue 1873, which changed the rules for this case ([class.access.base]/p5): A member m is accessible at the point R when named in class N if [...] m as a member of N is protected, and R occurs in a member or friend of class N, or in...

Is function object returned by std::mem_fn required to have a const overload

c++,c++11,clang,libc++

I don't see the standard specifying anything about the const-callability of the wrapper returned by mem_fn. From [func.memfn] (quoting N4140): template<class R, class T> unspecified mem_fn(R T::* pm); 1 Returns: A simple call wrapper (20.9.1) fn such that the expression fn(t, a2, ..., aN) is equivalent to INVOKE (pm, t,...

C++ GCC/MinGW Paths: ssp, ext, tr1; parallel, ext, bits, experimental

c++,gcc,clang,mingw-w64,libc++

(moving/expanding from the comments) I've always seen stuff being included explicitly from those locations, e.g. <bits/c++config.h>, <ext/bitmap_allocator.h>, <tr1/cmath> and the like, never adding one of those directories directly to the include search path. Notice that, as far as I always understood, the bits directory should be mostly left alone, as...

undefined reference to operator delete in destructor of istringstream from libc++

c++,gcc,clang,clang++

There was a recent change in clang trunk. The compiler does no longer emit weak definitions of the sized operator delete (see the commit 229241). The flag to emit the definitions anyway (-fdef-sized-delete) was renamed later in commit 229597. You have to compile your program with the -fdefine-sized-deallocation flag so...

When can/will a function be inlined in C++? Can inline behavior be forced?

c++,gcc,clang,compiler-optimization

As a rule, your code is always inlined only if you specify: __attribute__((always_inline)) eg (from gcc documentation): inline void foo (const char) __attribute__((always_inline)); Though it is almost never a good idea to force your compiler to inline your code. You may set a high optimization level (though the O flag)...

Building libobjc2 with CMake + Clang + MinGW on Linux

cmake,clang,cross-compiling,mingw-w64,libobjc2

Okay, so I figured that I would need to add -lobjc to the CMAKE_CXX_FLAGS, but it never occured to me to add a linker search path for the library. Running the following before make solves my problem: cmake .. -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS=$CLANG_WINDOWS_XFLAGS -DCMAKE_CXX_FLAGS="$CLANG_WINDOWS_XFLAGS -L`pwd` -lobjc" -DCMAKE_INSTALL_PREFIX=/opt/cross/windows/gnustep ...

How to detect SSE/AVX/AVX2 availability at compile-time ?

gcc,clang,sse,avx,avx2

Most compilers will automatically define: __SSE__ __SSE2__ __SSE3__ __AVX__ __AVX2__ etc, according to whatever command line switches you are passing. You can easily check this with gcc (or gcc-compatible compilers such as clang), like this: $ gcc -msse3 -dM -E - < /dev/null | egrep "SSE|AVX" | sort #define __SSE__...

C++ Grand Parent default constructor call

c++,clang

You should use member initializer list syntax to call appropriate Rect constructor with your arguments: Square(int width) : Rect(width, width) { printf("Square constructor called.\n"); } Notice that you don't need to manually assign to this->width and this->height, Rect constructor will do this for you. Main advantage of using initializer list...

clang - linking a static library with a pch file causes error with __STATIC__ disabled

objective-c,clang,static-linking,pch

When using the clang -cc1 option, the static compilation switch for the PCH header file is: -static-define (Also the main compilation and link should likely be using --static as opposed to -static; this is from the gcc documentation as opposed to the clang documentation)...

Private class specialization error

c++,c++11,clang

You can do it like this: #include <stdio.h> #include <string> enum class Car { BMW }; class C { static void Method() { puts("inner");} }; template<typename T> class BaseClass { private: template<typename V> struct Helper; template<typename V> using Info = Helper<V>; template<typename V> using InnerType = typename Info<V>::InnerType; private: T...

Disable clang warnings across functions

c++,clang,suppress-warnings

The warning is emitted for the comparison using ==, not for the call. If you have two functions that both call compare<float>, and you would somehow manage to suppress the warning for the first call, there wouldn't be anything left to warn for in the second call: compare<float> has already...

installing Rcpp on R compiled with intel composer on OSX Yosemite

r,clang,openmp,rcpp,intel-composer

Here's my best guess at what's going on. In Rcpp, we provide specializations for std::swap() here, with relevant bits copied for brevity: namespace std { #undef RCPP_GENERATE_SWAP #define RCPP_GENERATE_SWAP(TYPE,RTYPE) \ template<> inline void swap< Rcpp::internal::TYPE<RTYPE> >( \ Rcpp::internal::TYPE<RTYPE>& a , \ Rcpp::internal::TYPE<RTYPE>& b) { \ a.swap(b) ; \ } RCPP_GENERATE_SWAP(generic_proxy,VECSXP)...

C11 alignas vs. clang -Wcast-align

c,clang,memory-alignment,c11

From clang source, in SemaChecking.cpp:~7862, it seems they are only looking at types like you mention: CharUnits SrcAlign = Context.getTypeAlignInChars(SrcPointee); if (SrcAlign >= DestAlign) return; // else warn... It looks to me like clang is preparing for a c-style cast which in turn will check for cast alignment. void CastOperation::CheckCStyleCast()...

Is this code really undefined, as Clang seems to indicate?

c++,clang,undefined-behavior,libstdc++,sanitizer

This is a bug in libstdc++, from the cfe-dev mailing list thread with title -fsanitize=undefined and shared libraries says: This is a bug in libstdc++. You will be able to work around it with a sanitizer blacklist file, once Will's patch for that lands, but for now, filtering them out...

Linking against third-party libraries when doing cross-platform build in Visual Studio 2015

c++,android-ndk,cross-platform,clang,visual-studio-2015

First, the Opus Codec distribution comes with Visual Studio projects that are configured to build only Windows libraries, which are not cross-platform. You need to replace these projects with Cross Platform Library projects. Or better alternative: just download prebuilt libopus.a, e.g. from here. Second, you cannot use #pragma comment(lib, ...)...

Why are distinct Type objects being generated by Clang's parser for the same type?

c++,types,clang,abstract-syntax-tree

The reason for this is due to how clang interprets the return type of your function NS::X foo(); ^^^^^ According to the documentation, an ElaboratedType represents a type that was referred to using an elaborated type keyword, e.g., struct S, or via a qualified name, e.g., N::M::type, or both. This...

Why is a member template from private base class introduced with a using declaration inaccessible?

c++,visual-c++,gcc,compiler-errors,clang

[namespace.udecl]/p18: The alias created by the using-declaration has the usual accessibility for a member-declaration. Not much to say here. The name B::C is publicly accessible, and the code is well-formed. Just another MSVC bug....

How to display CGAL exceptions in command line lldb

c++,exception,clang,lldb,cgal

I don't know quite what you want to get. You can get lldb to stop at the point where the exception is going to be thrown by setting a breakpoint on the exception throw: (lldb) break set -n __cxa_throw Then you will stop in the debugger at the point where...

XCode6: Receiving error “Include of non-modular header inside framework module”

xcode,xcode6,clang,ios-frameworks

Select the .h file in the project navigator. In the target membership area on the right there is a drop down menu next to the target. Select "public" there (probably "project" is selected right now).

c++ operator overloading and associated namespace

c++,namespaces,operator-overloading,clang,argument-dependent-lookup

This is caused by two different CWG issues: CWG issue 2052 and CWG issue 1391. First, CWG 1391. On encountering x + a, the usual name lookup finds, among other overloads, template <typename T> double operator+ (T, double); Template argument deduction is performed by match T to the type of...

Overload resolution difference between gcc and clang involving move constructor and 'Derived(Base&&)' constructor

c++,c++11,gcc,clang,overload-resolution

I believe Clang is correct here. GCC should not be accepting the code. The reason is the way overload resolution for constructors for the object copy occurring in a return statement is specified in [class.copy] p32 (emphasis mine): When the criteria for elision of a copy/move constructor are met, [...],...

Why does clang's stdbool.h contain #define false false

c++,clang,language-lawyer

stdbool.h is a C header, not a C++ header. It is not usually found in C++ programs because true and false are already keywords in C++. Consequently, if a C++ program includes stdbool.h it is a fairly clear indication that it is a ported-over C program (e.g. a C program...

ruby extension for clang crash with segfault when GC delete Index object

ruby,clang,llvm-clang,ruby-c-extension

I have found the errors, the corrected code is : static VALUE c_Index_set_global_options(VALUE self, VALUE options) { Index_t *i; Data_Get_Struct(self, Index_t, i); if (TYPE(options) == T_FIXNUM || TYPE(options) == T_BIGNUM) //clang_CXIndex_setGlobalOptions(i,NUM2UINT(options)); clang_CXIndex_setGlobalOptions(i->data,NUM2UINT(options)); else rb_raise(rb_eTypeError, "invalid type for input"); return Qnil; } static VALUE c_Index_get_global_options(VALUE self) { Index_t *i; Data_Get_Struct(self, Index_t,...

Scoping rules for struct variables in GCC

c,gcc,struct,clang,scoping

As others mentioned, you're reading an uninitialized local variable and that's undefined. So, anything is legit. Having said that, there is a particular reason for this behavior: gcc reuses variables on the stack as much as it can (i.e., as long as the generated code is provably correct). You can...

Undefined symbols for architecture x86_64 (clang)

c,osx,openssl,clang,llvm

#include <openssl/evp.h> ... unsigned char outHash[20]; hash("SHA1","abcd", 20, outHash); OpenSSL does not have a int hash(...) or char* hash(...) function. $ cat /usr/include/openssl/evp.h | grep hash returns 0 hits. man 3 hash returns BSD's "hash database access method". Undefined symbols for architecture x86_64: "_hash", referenced from: _getRandomSHA1 in main-68ccd6.o...

no matching constructor for initialization of 'string' (aka 'basic_string')

c++,string,c++11,clang

I believe this is a clang bug. According to the rules for list-initialization in [dcl.init.list]: List-initialization of an object or reference of type T is defined as follows: If T is a class type and the initializer list has a single element of type cv U, where U is T...

Undefined symbols compiling in Mac OS X with Boost, GMP, and OpenMP

osx,gcc,boost,clang,gmp

The Mac OS X Installation instructions have been updated and everything works now if I just blindly follow them to the letter.

c++ inline function wrapping single vmovups in GCC inline assembly

c++,assembly,clang,inline,avx

By passing a pointer as the input argument you're loading the value of the pointer rather than what it points to. You need to pass the value you want to load. __m256 V8fLoadU(const float* pf) { __m256 m; __asm__("vmovups %1, %0" : "=x" (m) : "m" (*pf)); return m; }...

Parameter pack form of 'auto … arg' is enabled in lambda but not in function?

c++,gcc,parameters,lambda,clang

I found the answer by myself. It's stated in 'n4296' at § 5.1.2.5: The closure type for a non-generic lambda-expression has a public inline function call operator (13.5.4) whose parameters and return type are described by the lambda-expression’s parameter-declaration-clause and trailing-return-type respectively. For a generic lambda, the closure type has...

Converting from __m128 to __m128i results in wrong value

c++,type-conversion,clang,sse,intrinsics

Debugger, in this example, interprets the __m128i value as two 64-bit integers, as opposed to four 32-bit ones expected by you. The actual conversion is correct. In your code you need to explicitly specify how to interpret the SIMD value, for example: test_i.m128i_i32[0]...

What does a compiler check for uninstantiated template code?

c++,templates,gcc,clang,language-lawyer

The standard only requires the name-lookup to happen at phase 1, when the template is first parsed. This turns up badfoo in badbar which is why the code compiles. The compiler is not required to do the overload resolution at that time. The overload resolution (which always happens as a...

Can addresses of unmodified locals wind up corrupted in setjmp/longjmp?

c,clang,language-lawyer,longjmp,address-sanitizer

Is there a reason the helper call is "embedded" into the controlling expression of if through ?: operator? This is actually a violation of the language requirements that says 7.13.1.1 The setjmp macro 4 An invocation of the setjmp macro shall appear only in one of the following contexts: —...

different clang and gcc behavior with pointers

c++,c,gcc,clang

pointer_to_check to check is uninitialized. It points to some "random" location. Accessing uninitialized variables leads to Undefined Behavior which means that anything can happen. Also, pointers should be printed using the %p format specifier. with gcc code, we will get zero at output Anything can be the output. It is...

How to import private framework headers in a Swift framework?

ios,objective-c,swift,clang

You need to modify framework A, So that it export a private module. Create a private module map file in A project. This would be something like this: A/private.modulemap: explicit module A.Private { // Here is the list of your private headers. header "Private1.h" header "Private2.h" export * } In...

How do you Mark ASM code?

assembly,clang

clang will, by default, use its integrated llvm assembler, but this can be disabled with the command line option -fno-integrated-as. Specifying this along with -S should preserve the comments from the inline asm. Running clang -S -O3 -fno-integrated-as on the code sample #include <cmath> #define ASM_LABEL(label) asm ("#" label "\n\t"...

Which book teaches the inner workings of how Xcode builds apps from code?

ios,xcode,clang,llvm,bytecode

You can check this objc.io series of articles about build tools.

Inline function at -O0 causes link failure in clang [duplicate]

c,optimization,clang,inline,c99

At -O1 and greater it is not calling the function it just moves the code into main, we can see this by using godbolt which shows the asm as follows see it live: main: # @main pushq %rax movl $.L.str, %edi movl $42, %esi xorl %eax, %eax callq printf xorl...

#ifdef in separate header not working as expected

c++,gcc,clang

The #ifdefs where handled correctly by the compiler. The issue was related to the use of SWIG for wrapping the interface in Python/Java/R/Ruby/Octave/Tcl/Lua/C#. The defines were not passed to SWIG which therefore did not compile what was inside the #ifdef. Adding %include "sitkConfigure.h" to the SWIG .i file fixed the...

Build/install llvm/clang with both 32 & 64-bit support libraries

clang,llvm,32bit-64bit,libraries,building

Configure LLVM and Clang with -arch i386 -arch x86_64 i.e.: CFLAGS="-arch i386 -arch x86_64" \ CXXFLAGS="-arch i386 -arch x86_64" \ ./configure --prefix=/prefix --enable-optimized --disable-assertions ...

Explanation behind C++ Quiz by Olve Maudal (alias template)

c++,templates,gcc,clang,alias

I think it is 14.5.7 Alias templates 1 A template-declaration in which the declaration is an alias-declaration (Clause 7) declares the identifier to be a alias template. An alias template is a name for a family of types. The name of the alias template is a template-name. The above means...

Static library link issue with Mac OS X: symbol(s) not found for architecture x86_64

c,osx,clang,static-libraries,ar

The library should have generated with libtool -static. gcc -c io.c libtool -static -o libio.a io.o gcc main.c -lio -o main -L. main Returns 10 ar> lipo -info libio.a input file libio.a is not a fat file Non-fat file: libio.a is architecture: x86_64 ar> file libio.a libio.a: current ar archive...

C library crashes when optimization is turned off

c,xcode,clang,libwebsockets

It seems you did not initialize all the fields in the struct lws_context_creation_info, leading to undefined behaviour. Depending on compiler options and other less predictable circumstances, your program may actually seem to function correctly... by pure chance! You can fix this easily by clearing the structure with a memset: struct...

How to insist a C compiler put local variables on the stack, not in registers

c,gcc,garbage-collection,clang,tcc

I suppose that you use a kind of "mark and sweep" GC. In such case you only need to save registers at the moment when marking phase starts. My advise is to examine your GC, find the place where the "mark and sweep" operation starts and to put a code...

stop compilation switching to clang

clang

No, gcc is not installed as /usr/bin/gcc. Clang is installed as /usr/bin/gcc, because Apple doesn't ship gcc anymore. If you want gcc, you need to install it (presumably by saying brew install gcc) and then setting CC=/usr/local/bin/gcc.

Using TI Linker Command File with Clang

c++,clang,msp430

Clang is intended to be GCC compatible. TI's header files (msp430-gcc-support-files) use the following mechanism to define memory-mapped register variables: #define sfrw_(x,x_) extern volatile unsigned int x asm(#x_) #define sfrw(x,x_) sfrw_(x,x_) #define ADC12IFG_ 0x070A /* ADC12+ Interrupt Flag */ sfrw(ADC12IFG, ADC12IFG_); (This does not require a linker command file.)...

How to compile LLVM against a custom glibc?

vim,cmake,clang,llvm,glibc

Then I also tried LD_PRELOAD As explained here, in order to use custom glibc, you need to set correct --dynamic-linker. I see that you are using --dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux.so.2, but that doesn't look right: you need ld-linux-x86-64.so.2. export LD_PRELOAD='/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2 ... That (preloading of ld-linux) can never work: it's the ld-linux that...

Inconsistent behavior when sending parameters to a function with 0 parameters

c,gcc,visual-studio-2013,clang

From 6.5.2.2 Function calls: 2 - If the expression that denotes the called function has a type that includes a prototype, the number of arguments shall agree with the number of parameters. [...] VC is being deliberately permissive in order to permit compilation of (for compatibility with) incorrect code. This...

clang error: c++/4.8/bits/stl_iterator_base_types.h:227:29: error: no type named 'iterator_category' in 'std::iterator_traits'

c++,gcc,clang,libc++

Upgrade your clang version, it's very likely that clang 3.1 can't deal with the 4.8 libstdc++ headers. http://llvm.org/releases/download.html http://llvm.org/apt...

How to drill down into shared_ptr [Netbeans, clang++, gdb]

c++,debugging,gdb,clang,netbeans-8

One flaw of gdb is that the pretty-printing code is only for printing, and can't be used to dig deeper. This flaw also affects the "varobj" feature, which is what most GUIs use when communicating with gdb about value display. There are some possibilities that can make this better. First,...

How to call clang-format over a cpp project folder?

c++,clang,clang-format

What about: clang-format -i -style=WebKit *.cpp in the project folder. The -i option makes it inplace (by default formatted output is written to stdout)....

C++ clang array much faster than clang vector and both gcc vector and array

arrays,performance,c++11,gcc,clang

A 25x speedup tells you that your code was optimized out. Since your code does nothing visible it is eligible to be deleted. Your benchmark is invalid.

clang::HeaderSearch search path ignored

c++,clang,llvm,llvm-c++-api

Firstly, drop using CompilerInstance- the ownership semantics are so bad it's practically unusable (unless they fixed that in 3.6 with unique_ptr). It's easier to simply make the components yourself. Secondly, yes, you have to do it yourself. Here's a verbatim excerpt from my own project that uses Clang: clang::HeaderSearch hs(/*params*/);...

Readelf reports program is a shared library instead of executable

c++,makefile,android-ndk,clang

clang++ keeps producing .so shared library (checked with readelf - it is indeed shared object). Is there a special switch to compiler / linker that I have forgotten? My guess: readelf is outputting Elf file type is DYN (shared object file), and you are interpreting that to mean a...

Makefile configuration for entire system

c++,c,ubuntu,makefile,clang

Make uses Makefiles in the current directory and Implicit-Rules. You can modify the behavior of implicit rules by changing the variables that those explicit rules use. For example, to change the compiler for .cpp files, you could set your own CXX variable, either in the environment (Make uses it): CXX=clang++...

Xcode error: “_main”, referenced from: implicit entry/start for main executable

ios,xcode,clang

I checked your project. The issue is simple, in your project there is no main.m file. I think you accidentally deleted that. Add a new .m file to your project, name it as main And add the following code to it: #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char *...

Using Clang as an API

clang,llvm,code-generation

The short answer is no. A longer answer is that, Clang is just a compiler from C++ (and C and ObjC) to LLVM IR, going via the AST. Its external APIs all relate to compiling and analyzing C++. Once you parse a language like your sample to an AST, what...

incomplete type for std::unordered_set compiling error in g++5, compiles in clang++

c++,c++11,clang,incomplete-type,gcc5

It is undefined behavior to instantiate a standard library container with an incomplete type. [res.on.functions]/1, 2.5: 1 In certain cases (replacement functions, handler functions, operations on types used to instantiate standard library template components), the C++ standard library depends on components supplied by a C++ program. If these components do...

C - pthread_create - Clang GCC difference

c,gcc,pthreads,clang

The problem is most likely that you have no control over when the thread starts to run, so the spawn_bserver_thread function may exit before the thread function starts, meaning the sockfd variable goes out of scope and the pointer argument to the bserver_thread function is no longer valid.

Get AST for C fragment, using Clang?

clang

May be there are several ways to achieve this, but finally I got the following snippet working and to me it looks simple enough: //arguments to the compiler std::unique_ptr <std::vector<const char*>> args(new std::vector<const char*>()); args->push_back("my_file.c"); //do the magic ASTUnit *au = ASTUnit::LoadFromCommandLine( &(*args)[0], &(*args)[0] + args->size(), IntrusiveRefCntPtr<DiagnosticsEngine>( CompilerInstance::createDiagnostics(new DiagnosticOptions)), StringRef()...

Apple Mach-O Linker Error - ld: file not found: -ObjC

ios,objective-c,iphone,xcode,clang

Thanks everyone, I managed to sort it. @Droppy pointed me in the right direction. Before the -ObjC flag there was another called -force_all. I then stumbled across this answer which indicated that you only need the -ObjC flag. I removed -force_all and it started to work!...

Use emscripten from Clang compiled executable

c++,c,clang,emscripten

Porting to Emscripten is the same as porting to any other platform: you have to use that's platform's own platform-specific headers. Some will have nice equivalents, and some won't. In most cases you'll need to find these chains of platform-specific #if defined(...) and add an #elif defined(__EMSCRIPTEN__), and do the...

msbuild set path to CL

visual-studio,msbuild,clang

This is easy to do from either command line or project file. The properties you need to configure are $(CLToolExe) and $(CLToolPath). From the command line: msbuild MyProj.vcxproj /p:CLToolExe=clang-cl.exe /p:CLToolPath=c:\whatever\path\to\the\tool Alternatively, inside your .vcxproj file: <PropertyGroup> <CLToolExe>clang-cl.exe</CLToolExe> <CLToolPath>c:\whatever\path\to\the\tool</CLToolPath> </PropertyGroup> If you are calling task CL directly inside your .vcxproj file,...

clang -Xclang -cc1 -O3 mips.c -emit-llvm , clang error: -emit-llvm cannot be used when linking

c,clang,llvm

As written in the error message, you can only compile when emitting LLVM IR, not link. Either add -c for the bitcode or -S for the readable form to your command line: clang -Xclang -cc1 -O3 mips.c -emit-llvm -S ...

CLANG Static Code Analysis for iOS Development [closed]

ios,objective-c,clang,static-analysis,software-quality

A very important aspect of software quality and stability is unit testing. Unit testing will easily help identify bugs and crashes, although it is not a silver bullet or a cover all solution. Unit testing is part of the Xcode toolset now and can be run right from within Xcode....

Returning std::initializer_list in clang [duplicate]

c++,c++11,clang,clang++

From C++11 8.5.4 List Initialization [dcl.init.list]: 5 An object of type std::initializer_list<E> is constructed from an initializer list as if the implementation allocated an array of N elements of type E, where N is the number of elements in the initializer list. Each element of that array is copy-initialized with...

clang matchers. find the corresponding node in ast by translation unit, line number, and column

c++,clang

Resolved. I wasn't aware of cursors, thanks to Benjamin for pointing me in the right direction.See cursors for the function clang_getCursor which, providing it with a precise location in source code, returns the corresponding cursor into the AST, which then can be queried for kind, name, children, and location of...

How to name a single function-parameter-pack?

c++,parameters,clang,iso,pack

How about using normal template parameter packs like usual? Like e.g. template<typename T, typename... argsT> T *allocate(argsT... args) { return new T(std::forward<argsT>(args)...); } ...

error: expected unqualified-id on extern “C”

c++,c,clang,extern

The extern "C" linkage specification is something you attach to a function declaration. You don't put it at the call site. In your case, you'd put the following in a header file: #ifdef __cplusplus extern "C" { #endif void function_in_C(char const *); /* insert correct prototype */ /* add other...

Flycheck - disabling Clang as a checker *permanently*

emacs,clang,flycheck

You should be able to add c/c++-clang to the variable flycheck-disabled-checkers. From the documentation of this variable (C-h v flycheck-disabled-checkers): A list of Flycheck syntax checkers to exclude from automatic selection. Flycheck will never automatically select a syntax checker in this list, regardless of the value of `flycheck-checkers'. Simply add...