FAQ Database Discussion Community


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

ios,xcode,clang
I am getting the following error, which seems to be coming from something in the bottom to do with "_main". Ld /Users/jianglin/Library/Developer/Xcode/DerivedData/TownHall_iPhone-bdlgipvgaapgjhglhromfvcubbxz/Build/Products/Debug-iphonesimulator/TownHall\ iPhone.app/TownHall\ iPhone normal i386 cd "/Users/jianglin/Desktop/TownHall iPhone" export IPHONEOS_DEPLOYMENT_TARGET=8.1 export...

clang/llvm ARM instrinics

clang,llvm,intrinsics
Where can I find a complete list of intrinsics supported by clang/llvm targeting ARM? Everything I can dig up has to do with NEON, but what if I want to do something like a bit scan or a rotate? Side question: Are the intrinsics supported by clang or llvm?...

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

c++,c++11,clang,incomplete-type,gcc5
Consider the code related to a previous SO question C++ cyclic dependency confusion with adjacency list representation #include <cstddef> #include <unordered_set> class Node; class Hash { public: std::size_t operator()(const Node &node) const; }; class Node { public: int data; std::unordered_set<Node, Hash> links; }; inline size_t Hash::operator()(const Node &node) const {...

Get AST for C fragment, using Clang?

clang
I am building a clang plugin, and I am trying to generate the AST for a C fragment at some point within the plugin. Something like: std::string c_code = "..."; getAST(c_code); Can someone point me to, how to go about this?...

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

c++,gcc,clang,compiler-optimization
I am trying to get the expected behavior when I use the keyword inline. I tried calling a function in different files, templating the function, using different implementation of the inline function, but whatever I do, the compiler is never inlining the function. So in which case exactly will the...

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

ruby,clang,llvm-clang,ruby-c-extension
I am trying to write a little ruby extension for the c interface of clang. I am focusing on the CXIndex structure that I wrapp in a Clangc::Index class. I am able to compile it, load the module and create some Clangc::Index class like in this test: #!/usr/bin/env ruby require...

Converting from __m128 to __m128i results in wrong value

c++,type-conversion,clang,sse,intrinsics
I need to convert a float vector (__m128) to an integer vector (__m128i), and I am using _mm_cvtps_epi32, but I am not getting the expected value. Here is a very simple example: __m128 test = _mm_set1_ps(4.5f); __m128i test_i = _mm_cvtps_epi32(test); The debugger output I get: (lldb) po test ([0] =...

C11 alignas vs. clang -Wcast-align

c,clang,memory-alignment,c11
So I have the following minimized C11 code that defines a struct containing a uint16_t (which means the struct it should be aligned to 2 bytes) and I want to cast a char buffer to a pointer to that struct. With warnings turned all up, clang rightly complained that the...

How to display CGAL exceptions in command line lldb

c++,exception,clang,lldb,cgal
I usually debug my code by hand, but I am trying to use lldb to debug a CGAL project. Therefore, this is a newbie lldb question. The following code causes an exception (that is the expected behavior). When I compile and run the following code in Xcode (using os-x's built-in...

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

osx,gcc,boost,clang,gmp
I'm having problems compiling a program called SDPB by following these instructions. To summarize, I'm installing a program that requires Boost, GMP, and OpenMP on Mac OS X Yosemite. All the individual pieces of code compile but when its time to link, I get Undefined symbols for architecture x86_64. My...

How to import private framework headers in a Swift framework?

ios,objective-c,swift,clang
I have an Objective-C framework (framework A) that exposes some public and some private headers. The public headers are also declared in the framework's umbrella header. I have a second Swift framework (framework B) that links with the Objective-C framework. Now, if I want to import the public headers of...

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

c++,gcc,clang,clang++
I tried to build clang++ from trunk (~3.7) in a two ways: by means of gcc (4.8) and by means of (old) clang++ (3.4 and 3.5 from packet manager). Both of them consists of the same steps: export CC=clang export CXX=clang++ export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:$HOME/llvm/projects/libcxxabi/include" sudo apt-get install git cd git clone...

How to name a single function-parameter-pack?

c++,parameters,clang,iso,pack
The question is simple - I wasn't able to find a better example in the ISO C++ documentation then this: template<class ... targs> void func(targs ... args); But even for it I wasn't able to find a satisfying explanation. And this is not what I'm looking for as I don't...

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

c++,visual-c++,gcc,compiler-errors,clang
Consider the following (artificial) example: class A { public: template <typename T> class C {}; }; class B : private A { public: using A::C; }; int main() { B::C<int> c; } It compiles successfully with both GCC and Clang, but Visual C++ 2010 gives the following error: test.cpp(13): error...

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

c,gcc,clang,c11
In C11, there is the keyword _Noreturn which is a function specifier (like inline is) that indicates the function does not return — it calls exit() or equivalent. There is also a header, <stdnoreturn.h>, the complete definition for which is: 7.23 _Noreturn <stdnoreturn.h> ¶1 The header <stdnoreturn.h> defines the macro...

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

c,clang,language-lawyer,longjmp,address-sanitizer
If one winds up in the situation of being stuck using setjmp/longjmp (don't ask), then there are lots of nice warnings from the compiler about when you might be doing something wrong. But with a -Wall -Wextra -pedantic build while using Address Sanitizer in Clang, I wound up with a...

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

arrays,performance,c++11,gcc,clang
The code below shows my test cases. I compiled both with clang++ --std=c++11 -O2 and with g++ --std=c++11 -O2. long long *ary = new long long[100000000](); for (long long i = 0; i < 100000000; ++i) ary[i] = i; std::vector<long long> vec(100000000, 0); for (long long i = 0; i...

Scoping rules for struct variables in GCC

c,gcc,struct,clang,scoping
Consider the following C program #include <stdio.h> typedef struct s { int x; } s_t; int main() { int x; s_t a; scanf("%d", &x); if (x > 0) { s_t a; a.x = x; } printf("%d\n", a.x); } The a struct variable in the if branch clearly shadows the a...

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

ios,objective-c,iphone,xcode,clang
I've inherited an iOS project and can't even get it to build. I keep getting the following error: ld: file not found: -ObjC clang: error: linker command failed with exit code 1 (use -v to see invocation) I've seen posts about the 'file not found' error but none pertaining to...

ThreadSanitizer (tsan) - Meaningful information from shared library

c++,multithreading,clang,wxwidgets,thread-sanitizer
My app used the wxWidgets library, built from source via gcc 5.1.0, using -g and -O0 I compiled my app using clang++36 -g -fsanitize=thread -stdlib=libc++, and linked it using clang++36 -g -fsanitize=thread -stdlib=libc++ -lc++abi. It dynamically links to wxWidgets. One of the warnings I received was: ================== WARNING: ThreadSanitizer: lock-order-inversion...

different clang and gcc behavior with pointers

c++,c,gcc,clang
For example, we have the following simple code: #include "stdio.h" int main() { int* pointer_to_check; printf("%x\n", pointer_to_check); return 0; } With gcc, we will get zero at output (as for me, normal behavior, because pointer isn't associated with memory), but clang gives us a real address, which can be accessed...

clang::HeaderSearch search path ignored

c++,clang,llvm,llvm-c++-api
I'm trying to get clang::CompilerInstance to parse a source file which contains an include, but I can't figure out how to get it to actually find the included header. Here is my set up: std::unique_ptr<clang::CompilerInstance> ci(new clang::CompilerInstance()); ci->createDiagnostics(); LLVMInitializeARMTarget(); LLVMInitializeARMTargetMC(); LLVMInitializeARMAsmPrinter(); LLVMInitializeARMAsmParser(); std::shared_ptr<clang::TargetOptions> options(new clang::TargetOptions); options->Triple = "arm-v7m-unknown-none-eabi";...

CLANG Static Code Analysis for iOS Development [closed]

ios,objective-c,clang,static-analysis,software-quality
I am fairly new to project management of iOS development projects and I have been working on my first challenge. I am trying to make proactive use of tools that will increase software quality. I have two questions: a.For iOS development, do you think CLANG Static Code Analysis tool will...

Is this code valid or not? GCC and Clang disagree

c++11,gcc,clang,initializer-list
The following code gives me different results on GCC and Clang. Who's right? union Foo { struct { int a; int b; }; }; struct Bar { Bar(void) : test{.a = 1, .b = 2} { } Foo test; }; I get the following error with GCC (and it compiles...

Uninstalling gcc completely in Mac OS X Yosemite?

xcode,osx,gcc,clang,osx-yosemite
I am trying to uninstall gcc completely from my mac but unable to do so. Current status : ➜ ~ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0 /5.0.0/lto-wrapper Target: x86_64-apple-darwin14.0.0 Configured with: ../gcc-5-20141005/configure --enable languages=c++,fortran Thread model: posix gcc version 5.0.0 20141005 (experimental) (GCC) ~ which gcc /usr/local/bin/gcc I had...

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

ios,objective-c,xcode,clang
I tried renaming my project and Xcode crashed and wouldn't open again so I created a new project and copied the files I needed in and built the project to be presented with this error...I have no clue how to fix this..Kind of desperate here..really need help duplicate symbol _response...

error: expected unqualified-id on extern “C”

c++,c,clang,extern
I have a cpp code in which I want to call a c function. Both compile well to .o files, but when the clang++ is executing for compilation, I receive the following error: file.cpp:74:12: error: expected unqualified-id extern "C" ^ The code in the cpp file is the following: void...

Same FLT_EVAL_METHOD, different results in GCC/Clang

c,gcc,floating-point,clang
The following program (adapted from here) is giving inconsistent results when compiled with GCC (4.8.2) and Clang (3.5.1). In particular, the GCC result does not change even when FLT_EVAL_METHOD does. #include <stdio.h> #include <float.h> int r1; double ten = 10.0; int main(int c, char **v) { printf("FLT_EVAL_METHOD = %d\n", FLT_EVAL_METHOD);...

Clang ast-dump doesn't show some global variables

c++,clang,abstract-syntax-tree
I have a CPP file and I'm using clang to print all variables in global scope. The problem is following: command clang -cc1 -ast-dump filename.cpp doesn't show some global variables: |-VarDecl 0x2094370 N 'int' invalid |-VarDecl 0x20943e0 MAXN 'const int' invalid |-VarDecl 0x2094470 p 'int' invalid |-VarDecl 0x20944e0 u '_Bool'...

Is this incorrect code generation with arrays of __m256 values a clang bug?

c++,clang,compiler-optimization,avx2
I'm encountering what appears to be a bug causing incorrect code generation with clang 3.4, 3.5, and 3.6 trunk. The source that actually triggered the problem is quite complicated, but I've been able to reduce it to this self-contained example: #include <iostream> #include <immintrin.h> #include <string.h> struct simd_pack { enum...

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

c++,types,clang,abstract-syntax-tree
I have the following snippet that I'm parsing using Clang's API for a tool I'm writing: namespace NS { struct X { }; } struct Y { NS::X foo(); }; I use a (type that derives from) RecursiveASTVisitor to visit the AST. When the VisitCXXRecordDecl() function is invoked, I can...

C library crashes when optimization is turned off

c,xcode,clang,libwebsockets
I'm writing a library in C on Mac OS X, using XCode 6. The library is basically a plugin loaded by X-Plane and provides data out via a web socket server. The library, in turn, uses the libwebsockets library, which I compiled using the the guide from the developers repository...

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

c,optimization,clang,inline,c99
This question already has an answer here: Is “inline” without “static” or “extern” ever useful in C99? 3 answers I'm trying to compile the following code with clang at various optimization levels: #include <stdio.h> inline int foo() { return 42; } int main() { printf("%d\n", foo()); } At -O1,...

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++
Custom built clang 3.1 was unable to find some machine-dependent include files(like bits/c++config.h) from libc++, so I had to add manually: -I/usr/include/x86_64-linux-gnu/c++/4.8 into command line. gcc has no problem finding those files. Now I am trying to compile a file with clang++. gcc(with the same options) compiles it, complaining only...

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

c,osx,clang,static-libraries,ar
I'm trying to generate a static library and link it with an execution binary. This is a library function: #include <stdio.h> int hello() { return 10; } With these commands, I could get a static library. gcc -c io.c ar -crv libio.a io.o With lip -info, I checked it is...

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

c++,android-ndk,cross-platform,clang,visual-studio-2015
I am trying to compile a Shared Object (.so) with Visual Studio 2015 RC. I am linking against the Opus Codec libs in my stdafx.h: #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\celt.lib") #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\opus.lib") #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\silk_common.lib") #pragma comment(lib, "..\\..\\opus-1.1-beta\\win32\\VS2010\\Win32\\Debug\\silk_fixed.lib") #pragma comment(lib,...

Returning std::initializer_list in clang [duplicate]

c++,c++11,clang,clang++
This question already has an answer here: lifetime of a std::initializer_list return value 2 answers Consider this sample of code: #include <initializer_list> #include <iostream> int main() { for(auto e: []()->std::initializer_list<int>{return{1,2,3};}()) std::cout<<e<<std::endl; return 0; } I tried to compile it with g++ (gcc version 4.9.2 (Debian 4.9.2-10)) and the output...

msbuild set path to CL

visual-studio,msbuild,clang
I'm trying to take a couple of projects normally compiled on Windows with Microsoft C++ and compile them with clang instead. On the upside, there exists clang-cl.exe which is designed to be a drop-in replacement for cl.exe. However, even when I copy clang-cl.exe into the current directory as cl.exe, msbuild...

Building libobjc2 with CMake + Clang + MinGW on Linux

cmake,clang,cross-compiling,mingw-w64,libobjc2
I'm trying to cross compile libobjc2 from Arch to Windows. I use the following command to configure with CMake: 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 -DCMAKE_INSTALL_PREFIX:PATH=/opt/cross/windows/gnustep CLANG_WINDOWS_XFLAGS is defined as: export CLANG_WINDOWS_XFLAGS="-target x86_64-w64-mingw32 -nostdinc -isystem /usr/lib/clang/3.6.0/include -isystem...

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

xcode5,clang,llvm,osx-mavericks,kivy
Hi I am getting the error saying clang: error: unknown argument: '-mno-fused-madd' when I am trying to install kivy in virtualenv named kivyprogramming. cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -Wno-error=unused-command-line-argument-hard-error-in-future -pipe...

Using Clang as an API

clang,llvm,code-generation
I don't know much about Clang APIs, so forgive the silly question. If I am building a compiler for a language which have the same or similar features to C++, can I use Clang APIs to take responsibility for the code generation for me? For example, say I implemented a...

Clang (3.6.0) ignores warnings from included header files

c++,clang,clang++
It seems that clang is ignoring warnings which occur in included header files: // what.hpp class What { public: What() { int x = x; } }; // main.cpp #include <iostream> #include "what.hpp" int main() { int y = y; std::cout << "y is: " << y << std::endl; What...

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

c,gcc,garbage-collection,clang,tcc
I am trying to port an historical functional language interpreter (KRC for EMAS) to modern systems (C for Unix) and it has a garbage collector that expects to be able to scan the stack for pointers into the heap to know which pointers it must relocate when objects in the...

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

c++,templates,gcc,clang,alias
The following code is from http://www.pvv.org/~oma/PubQuiz_ACCU_Apr2014.pdf (#6, solution on page 34). The goal was to guess the output for the following. #include <iostream> template <template <typename> class> struct X { X() { std::cout << "1"; } }; template<typename > struct Y {}; template<typename T> using Z = Y<T>; template<> struct...

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

ios,objective-c,clang,linker-error,quickblox
Yesterday I updated the quickBlox frame work, since then I am not able to run the application in device, the app is running fine on simulator. its give me bellow error when I try to run in device. any help would be appreciated. ...

C - pthread_create - Clang GCC difference

c,gcc,pthreads,clang
Passing the argument to pthread_create with clang (3.6.1) and gcc (5.1.0) brings different results for a strange case, illustrated here: pthread_t spawn_bserver_thread(uint16_t portno) { pthread_t tid; int32_t sockfd = create_bserver(portno); set_nonblocking(sockfd); exit_ncurses(); printf("%d\n", sockfd); if(pthread_create(&tid, NULL, bserver_thread, &sockfd) != 0) error("pthread_create"); return tid; } and bserver_thread: static void * bserver_thread(void...

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

c,gcc,macros,clang,c-preprocessor
Code: char *color_name[] = { "red", "blue", "green" }; #define color_num (sizeof(color_name)/sizeof(char*)) int main(){ printf("size %d \n",color_num); return 0; } It works fine with GCC 4.8.2 on Centos 7. But I got error running above program on mac which says: note:expanded from macro 'color_num' Compiler on my Mac: ……include/c++/4.2.1 Apple...

How to compile LLVM against a custom glibc?

vim,cmake,clang,llvm,glibc
I'm using YouCompleteMe Vim plugin for text completion (installed through Vundle). YouCompleteMe uses Clang for text completion for C-family languages (C, C++, Objective-C, Objective-C++). However, after YouCompleteMe update (via :VundleUpdate in Vim) YouCompleteMe ceased to work. In short, the question is: How can I compile Clang against a custom glibc...

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

c++,clang
Different compiler seems to have different opinion on the subject. The following code compiles fine with gcc, but fails with clang: class Base { protected: static void f() {} }; class Derived : public Base { friend class DerivedFriend; }; class DerivedFriend { public: void g() { Base::f(); } };...

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

ios,xcode,clang,llvm,bytecode
I do iOS development and I'd like to have a deeper understanding of what is happening under the hood with Xcode. Things like byte code, virtual machines, object files, bundles, executables, etc. And ideally, I'd like to know how all of these ideas tie into Xcode. Which book should I...

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

c++,visual-studio,gcc,clang
I am trying to port my code from linux to windows. However with Visual Studio my code crashes with the following error: Microsoft C++ exception: std::bad_function_call at memory location This is my code: #include <functional> class Foo { public: Foo(int) : m_deleter{ []() {} } {} Foo(const Foo &) =...

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

objective-c,xcode,linker,clang
With Apple Generic Versioning enabled, Xcode autogenerates a MyFramework_vers.c file in the DERIVED_SOURCES_DIR, which contains the version string and number defined as const unsigned char[] and const double. However, with -Wmissing-variable-declarations enabled (part of -Weverything), this produces the warnings no previous extern declaration for non-static variable 'MyFrameworkVersionString' no previous extern...

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

c++,clang
hello and thx in advance for your help. i recently made some efforts to understand the clang matching system and got stuck on a specific problem. having a source file in an editor with a cursor set to a position in a line, thus having a precise location, is there...

Readelf reports program is a shared library instead of executable

c++,makefile,android-ndk,clang
got this strange behaviour with standalone Android NDK r10e Toolchain (built with --toolchain=x86-clang3.6 switch). Environment variables for cross compilation have been set before running makefile, SYSROOT points to Android toolchain location, CXX equals i686-linux-android-clang++. Basically, I have a bunch of cpp files that I would like to compile to Android...

Use emscripten from Clang compiled executable

c++,c,clang,emscripten
Is it possible to execute emcc (from emscripten) on a clang compiled executable ? I tried but the result is: ERROR root: pdfium_test: Input file has an unknown suffix, don't know what to do with it! I try that because I'm not able to find a solution to compile PDFium...

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

clang,llvm,doxygen
I want to get a copy of the doxygen web-pages of llvm, so I can work with it without the internet. I did as follows: $ cd LLVM_ROOT_DIR $ mkdir out $ cd out/ $ ../configure --enable-doxygen $ make ENABLE_OPTIMIZED=1 But it only built llvm without documentation. I also tried...

Undefined symbols for architecture x86_64 (clang)

c,osx,openssl,clang,llvm
I'm trying to use OpenSSL to compute sha1 hash from a c program. I am compiling with clang on Mac OS X Yosemite with an Intel i7 (so 64 bit). The relevant piece of code is roughly like so: #include <openssl/evp.h> ... unsigned char outHash[20]; hash("SHA1","abcd", 20, outHash); The thing...

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

c,clang,llvm
I want to use the clang front-end to convert mips.c to mips.ll which is a llvm IR. So I use the command: clang -cc1 O3 mips.c -emit-llvm. A fatal error occurs: 'stdio.h'(which is included in mips.c) file not found. Then I change the command as following: clang -Xclang -cc1 O3...

Clang Pragma Comprehensive List

xcode,clang,llvm
Where can I find the documentation of all possible #pragmas available in Xcode's Clang/LLVM? I found this in the Clang user manual, that at NSHipster, and even tried grepping through the svn repo, but still could not find documentation for things like _Pragma("clang assume_nonnull begin"). Any hints where to look?...

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

clang,llvm
I want to modify the AST by clang LibTooling. How can I clone an AST node or add a new one, e.g. I'd like to create a BinaryOperator with ADD opcode

How can I parse a C format string in Python?

python,c,regex,clang,pycparser
I have this code in my C file: printf("Worker name is %s and id is %d", worker.name, worker.id); I want, with Python, to be able to parse the format string and locate the "%s" and "%d". So I want to have a function: >>> my_function("Worker name is %s and id...

Is free() zeroing out memory?

c,gcc,memory-management,clang,free
Until today I lived in belief that calling free() on memory space releases it for further allocation without any other modifications. Especially, considering this SO question that clearly states that free() DOESN'T zero out memory. Yet, let's consider this piece of code (test.c): #include<stdlib.h> #include<stdio.h> int main() { int* pointer;...

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

gcc,clang,sse,avx,avx2
I'm trying to optimize some matrix computations and I was wondering if it was possible to detect at compile-time if SSE or/and AVX or/and AVX2 is enabled by the compiler ? Ideally for G++ and Clang, but I can manage with only one of them. I'm not sure it is...

Flycheck - disabling Clang as a checker *permanently*

emacs,clang,flycheck
I use Flycheck to check C files, and have a fairly elaborate variable setup for GCC to allow it to work correctly. However, due to having Clang on my system (for reasons unrelated to code), Flycheck always assumes that this is what I want to use, forcing me to manually...

Private class specialization error

c++,c++11,clang
During compilation the code below in clang i have warning (in vc++ it works fine): warning : explicit specialization of 'Helper' within class scope is a Microsoft extension [-Wmicrosoft] #include <stdio.h> #include <string> enum class Car { BMW }; class C { static void Method() { puts("inner");} }; template<typename T>...

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

c++,assembly,clang,inline,avx
I'm trying to work around an apparent bug in the clang compiler where using the AVX intrinsic _mm256_loadu_ps results in unnecessary instructions being output in assembly. In particular, first it does a vmovups on the first half of the input vector into an xmm register, then joins the second half...

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

c++,gcc,clang,mingw-w64,libc++
Question: In the GCC/MinGW folder tree, there are duplicates of some header file names, in folders: ssp, ext, tr1; parallel, ext, bits, and experiemental ... Should explicit "include" directives for these folders be avoided in production code--as a best practice? OR, is there documentation online, regarding the legitimate scenarios these...

What does a compiler check for uninstantiated template code?

c++,templates,gcc,clang,language-lawyer
For example, the following code piece compiles with gcc-4.9 and clang-602 class Base { public: static void foo() {} void badfoo(int i) {} }; template <typename T> class Derived : public Base { public: void bar() { Base::foo(); } void badbar() { Base::badfoo(); } // compiles ok //static void badbar()...

C++ Grand Parent default constructor call

c++,clang
I have the following code that runs just fine as long as I have the Rect default constructor included. However if I comment it out hope that it will just 'skip' to the Shape default constructor it fails to compile. #include <cstdio> class Shape { public: Shape() { printf("Shape default...

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

c++,c++11,gcc,clang,overload-resolution
GCC (tested with 4.9) accepts the following testcase: struct Base {}; struct Derived : Base { Derived(); explicit Derived(const Derived&); explicit Derived(Derived&&); explicit Derived(const Base&); Derived(Base&&); }; Derived foo() { Derived result; return result; } int main() { Derived result = foo(); } Clang (tested with 3.5) rejects it with...

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

linux,windows,multithreading,c++11,clang
EDIT I solved my problem by using a single mutex variable in the Shared struct instead of the multiple mutexes in Unique. If someone understands why this works and the other one doesn't (reliably) I will gladly accept an answer. EDIT I wrote a simple thread pool with c++11 threads....

Makefile configuration for entire system

c++,c,ubuntu,makefile,clang
As we know, in the appliance when we use the command make [file-name] It automatically compiles with some flags: -ggdb -O0 -std=c99 -Wall - Werror I need to know in which directory the CS50 edited Makefile is located, because I want to configure my own Makefile for the entire system...

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

c++,string,c++11,clang
Here is the code: #include <iostream> #include <string> using namespace std; class Foo { public: operator string() const { return n; } string n {"foo"}; }; int main (int argc, char** argv) { string s {Foo{}}; cout << s << endl; return 0; } This code compiles using gcc 4.8.3,...

c++ operator overloading and associated namespace

c++,namespaces,operator-overloading,clang,argument-dependent-lookup
The following simplified example compiles in gcc and Visual Studio, but fails in clang !? namespace N { struct A {}; template <typename T> double operator+ (T a, double d) {return d;} template <typename T> double operator+ (double d, T a) {return d;} } void test() { N::A a; double...

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

clang,llvm,32bit-64bit,libraries,building
My (built from source) llvm/clang install is able to create 32/64-bit executables fine, but when I created the installation it only produced 64-bit libraries (eg, libclang). I've sifted through their documentation, looked through the configure help, etc. As best I can tell my only option is to configure targeting a...

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

objective-c,clang,static-linking,pch
Am currently trying to link a bunch of Objective C modules into a static library. I am getting the following error and am unable to locate any information on how the __STATIC__ can not be disabled when building a PCH file. error: __STATIC__ predefined macro (as opposed to __DYNAMIC__) was...

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

c++,debugging,gdb,clang,netbeans-8
I'm using Netbeans C++ 8.0.2 clang++ (Ubuntu clang version 3.6.0-2ubuntu1 (tags/RELEASE_360/final) (based on LLVM 3.6.0)) gdb (GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9) In my "C++ Simple Tests," whenever I inspect a variable that is a shared_ptr, all I see for value is: std::shared_ptr (count 1, weak 0) 0x64d3a0 or similar. There...

How to increment a Global Variable in a LLVM module?

c++,clang,llvm
I want to add an instruction at the end of a basic block to increment a GlobalVariable (using the LLVM C++ library). I am pretty new to to the LLVM, can I do this directly or does this require loading the global variable, incrementing it by the desired value and...

clang 3.6 fold expression left/right

c++,clang,clang++,c++1z
I'm trying the fold expression with clang 3.6 '--std=c++1z', but something I don't quite get. The function that I'm testing is: auto minus = [](auto... args) { return (args - ...); }; ... std::cout << minus(10, 3, 2) << std::endl; according to n4191, I'm expecting it expands as a left...

Disable clang warnings across functions

c++,clang,suppress-warnings
In clang we can ignore warnings as described here. In my example this works fine if the code is directly enclosed in the pragmas (see (1)). However this doesn't work at (2) because the offending code is inside a function (3). The warning is only ignored if I enclose the...

C++ redefinition of variable, global namespace polluted and I don't know why

c++,osx,c++11,compilation,clang
so I think I've done something really stupid and I just can't figure this out. The following program is causing me a lot of pain: #include <iostream> int time = 0; int main(int argc, char **argv) { std::cout << "hi" << std::endl; return 0; } My compile string is: clang++...

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

c++,clang,undefined-behavior,libstdc++,sanitizer
I switched on -fsanitize=undefined on my project which uses Catch, the unit testing library. One line from Catch was signalled as causing undefined behaviour by this flag. I managed to make an isolated example: #include <iomanip> #include <sstream> int main() { std::ostringstream os; os << "0x" << std::setfill('0') << std::hex;...

#ifdef in separate header not working as expected

c++,gcc,clang
I have a #define in a separate header file: #ifndef __sitkConfigure_h #define __sitkConfigure_h #define SITK_4D_IMAGES #endif // __sitkConfigure_h (full source: https://github.com/kaspermarstal/SimpleITK/blob/8be437486dce85da271576f866393cd54fe0f865/Code/Common/src/sitkConfigure.h.in. The define is managed by a #cmakedefine and turns into #define SITK_4D_IMAGES as expected when cmake is configured.) As usual the header is included where the config is needed....

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

c++,c++11,clang,libc++
When I run this code with libc++: struct foo { foo(int x) : x(x) {} int x; }; int main() { const auto select_x = std::mem_fn(&foo::x); foo f(1); printf("%i\n", select_x(f)); } I get an error like this: mem_fn.cpp:16:20: error: no matching function for call to object of type 'const std::__1::__mem_fn<int...

Can constexpr be combined with volatile?

c++,c++11,gcc,clang,language-lawyer
The following snippet works fine in Clang 3.5 but not in GCC 4.9.2: int main() { constexpr volatile int i = 5; } with error: error: both 'volatile' and 'constexpr' cannot be used here If I inspect the assembly that Clang generates, it shows 5 as expected: movl $5, -4(%rsp)...

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

c++,c,clang,llvm,mingw-w64
1 hour ago I downloaded llvm-3.6.0-rc4-win32.exe from http://llvm.org/pre-releases/3.6.0/ . I tried to compile simple C code that just print "hello" , but it didn't compile , because clang.exe can't find stdio.h. when I use clang-cl.exe with the same code , it worked . I also have the same problem with...

How to set compiler-specific flags with autotools

gcc,clang,autotools,compiler-options
We use autotools as our build infrastructure, and we use clang and gcc as compilers. Recently we hit a gcc warning that needed --param max-vartrack-size=100000000 to silence (without completey disabling gcc's vartracking). Clang doesn't accept that option and produces argument unused during compilation: '--param max-vartrack-size=100000000' To silence that, clang needs...

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

c++,clang,clang-format
Is there a way to call something like this "clang-format --style=Webkit" over the cpp project folder rather than running it separately inside each code? I am using the clang-format.py and vim to do this. But I assume there is an easier way to apply this once....

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

c++,clang,llvm,jit
I am trying to use clang+llvm 3.6 to JIT compile several C functions (each can eventually be very large). Unfortunately I the function pointer that LLVM provides makes the program SEGFAULT. So far I have following code: #include <iostream> #include <clang/CodeGen/CodeGenAction.h> #include <clang/Basic/DiagnosticOptions.h> #include <clang/Basic/TargetInfo.h> #include <clang/Basic/SourceManager.h> #include <clang/Frontend/CompilerInstance.h> #include...

stop compilation switching to clang

clang
No matter what I try, any compilation I attempt always calls clang. For example, in CMake, setting CC=/usr/bin/gcc has no effect and clang is still called. In terminal entering any compiler results in clang being called: ~/tinyos-main/tools$ nescc clang: error: no input files ~/tinyos-main/tools$ gcc clang: error: no input files...

Inconsistent behavior when sending parameters to a function with 0 parameters

c,gcc,visual-studio-2013,clang
The following code produces a compilation error on both clang (3.6.0) and gcc(4.9.2) (coliru link) #include <stdio.h> void foo(void){ printf("lalala\n"); } int main(void) { foo(1, 2, 3, 4, 5, 6, 67); return 0; } While VS2013 (while being compiled with /TC /W4) only produces a warning warning C4087: 'foo' :...

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

c++,clang,language-lawyer
After being pointed there by a compiler error, I noticed clang's stdbool.h file includes (among other things) the following lines: #define bool bool #define false false #define true true They're contained in an #ifdef block that enforces __cplusplus indirectly, hence the c++ tag even though stdbool.h is a C header....

gcc doesn't accept pack expansion in default template argument

c++,c++11,gcc,clang
Following code is compiled successfully with clang, but gcc fails: struct fn { template <typename ... Args> static constexpr bool call (Args ... ) { return true; } }; template <typename ... T> static constexpr bool f = false; template <typename ... Ts, bool F = fn::call(f<Ts> ...)> void hoge...

LLVM: intermediate bytecode vs binary

clang,llvm
I'm confused about one aspect of LLVM: For all the languages it supports, does it support compiling both to the intermediate code AND to straight binary? For instance, if I write something in C, can LLVM (or Clang?) compile to either binary (like GCC) or intermediate code? Or can only...

Installing twitcurl on OS X

c++,osx,twitter,makefile,clang
I am attempting to install twitcurl on OS X and have met with some problems. At first, running make would return the clang error: ld: unknown option: -soname. I looked through the responses from other users with similar problems on OS X and found the following advice: In the makefile,...

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

c++,gcc,parameters,lambda,clang
Can someone explains me why a parameter can be declared as 'auto ... arg' in this context (when used in a lambda): auto glambda = [](auto a, auto&& b) { return a < b; }; bool b = glambda(3, 3.14); // OK auto vglambda = [](auto printer) { return [=](auto...

installing Rcpp on R compiled with intel composer on OSX Yosemite

r,clang,openmp,rcpp,intel-composer
Inspite of succeeding with the compilation of R-3.1.2 using the intel suite of compilers ver.2015.0.077 including MKL on my late 2014 MacBook Pro running Yosemite (outlined here), I am unable to install the excellent Rcpp package that I have been thoroughly enjoying thus far via the prepackaged binary R for...

How do you Mark ASM code?

assembly,clang
I am trying to mark my ASM (generate by the compiler) to make a postpone analysis between my mark my analysis the corresponding .s file. The following MACRO works with GCC #define ASM_LABEL(label) asm ("#" label "\n\t") Nevertheless with CLANG the label is removed. void kernel(double const * x, double...

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

xcode,xcode6,clang,ios-frameworks
I have an iOS app that consists of an app, a bunch of my custom frameworks, and a bunch of third party framweorks: App MyFramework1 MyFramework2 AFNetworking.framework Mantle.framework .. I get the error "Include of non-modular header inside framework module" with the following structure: App/AppDelegate.m #import <MyFramework2/MyFramework2.h> MyFramework2/MyFramework2.h #import "MyClass.h"...

Using TI Linker Command File with Clang

c++,clang,msp430
When using TI (Texas Instrument) compiler, I am able to set a memory location of embedded micro-controller using C++ by simply ADC12IFG = 50;. Clang marks this code as error: indirection requires pointer operand ('int' invalid). So when I dig into it, TI has a header file, msp430f5335.h which has...