clang

Can an inline variable be changed after initialization in C++17?

心已入冬 提交于 2020-01-03 07:19:32
问题 My scenario is the following (it worked in clang but not in gcc) liba.hpp: inline int MY_GLOBAL = 0; libother.cpp: (dll) #include "myliba.hpp" void myFunc() { // MYGLOBAL = 28; } someexe.cpp: RunAppThatUsesBothLibAandLibOther(); The problem is that the inline variable was showing 0 in places where I expected 28 because it was alrady modified at run-time. MSVC disagrees with this, but clang does the thing I would expect. The question is: can inline variables be modified at run-time in my

Can an inline variable be changed after initialization in C++17?

巧了我就是萌 提交于 2020-01-03 07:19:18
问题 My scenario is the following (it worked in clang but not in gcc) liba.hpp: inline int MY_GLOBAL = 0; libother.cpp: (dll) #include "myliba.hpp" void myFunc() { // MYGLOBAL = 28; } someexe.cpp: RunAppThatUsesBothLibAandLibOther(); The problem is that the inline variable was showing 0 in places where I expected 28 because it was alrady modified at run-time. MSVC disagrees with this, but clang does the thing I would expect. The question is: can inline variables be modified at run-time in my

How to cross-compile llvm/clang for ios simulator?

99封情书 提交于 2020-01-03 05:22:06
问题 export CC="clang -arch i386 -mios-version-min=5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk" export CXX="clang++ -arch i386 -mios-version-min=5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk" ../llvm_34_ios/configure --prefix=/Users/admin/llvm_34_ios_i386_installed --host=i386-apple-darwin11 --enable-optimized --disable-assertions

Linker error: /usr/bin/ld: cannot find -lc

别来无恙 提交于 2020-01-03 02:25:08
问题 I am trying to compile this code for some time. Specifically, I am trying to compile the avx2 code using the given mac. However, I am always getting the following error. I have looked up a lot but unable to find a solution. I will be very glad if you help me to find a solution. /usr/bin/ld: cannot find -lc collect2: error: ld returned 1 exit status make: *** [test/test_kyber] Error 1 gcc version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) Copyright (C) 2015 Free Software Foundation, Inc. This

Using ASM command in C

有些话、适合烂在心里 提交于 2020-01-02 08:46:28
问题 I have a small question about using ASM in c. I want to execute the instruction: LDR PC,=0x123456 This gives me the error "unexpected token in operand". asm("LDR PC,=0x123456"); This gives "invalid constraint". asm("LDR PC," : "m" (0x123456)); What's the right way to do this? 回答1: You are using this: asm("LDR PC,=0x123456"); This is not a standard ARM assembly instruction, but a pseudo-instruction provided as a compiler extension. This pseudo-instruction is converted to other assembly

failing to parse C++ using llvm and clang

五迷三道 提交于 2020-01-02 07:05:55
问题 I'm writing a little tool with llvm to parse C and C++ code, but I can't seem to get it to successfully parse C++ at all. I'm probably missing something obvious. This is what I have so far: #include <iostream> #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Frontend

Visibility linker warnings when compiling iOS app that uses Boost

我的梦境 提交于 2020-01-02 07:02:52
问题 My iOS app uses a library which in turn depends on Boost. While revamping the 3rdparty build system, I encountered linker warnings such as this ld: warning: direct access in ___cxx_global_var_init to global weak symbol std::__1::basic_ofstream<char, std::__1::char_traits<char> >::~basic_ofstream() means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. and this ld: warning: direct access in

How to install clang 3.1 using macports? (OSX, snow leopard)

六眼飞鱼酱① 提交于 2020-01-02 05:15:33
问题 I'd like to install the latest clang (3.1) compiler using macports (I use emacs rather than xcode, and the version of clang that comes with xcode is older anyway). macports seems to have the latest versions of gcc, but when I enter "port list clang" the only version that shows up is 2.9. I use the C++11 features, so I want to use the latest version. I'm running snow leopard on an MBP. 回答1: Clang has several different versions available on MacPorts: $ port search clang clang @2.9 (lang) C, C++

Why Can const lvalue References Refer to Mutable rvalue References?

会有一股神秘感。 提交于 2020-01-02 04:10:09
问题 In C++11 a const lvalue reference can be initialized with a mutable rvalue reference. The value referred to by the rvalue can then change producing a visible mutation to what the const lvalue is referring to. Here is an example: int && rval = 3; const int & lval = rval; cout << "lval = " << lval << endl; cout << "rval = " << rval << endl; rval ++; cout << "lval = " << lval << endl; Output (from clang 3.2 and gcc 4.8.2 both with -std=c++11): lval = 3 rval = 3 lval = 4 I would guess the reason

How do I forward-declare a constexpr object at namespace scope?

[亡魂溺海] 提交于 2020-01-02 02:28:05
问题 On clang (trunk) I can forward declare an object that will later be defined with constexpr as follows: // Fwd-declarations struct S; extern const S s; // (... later) definitions struct S {}; constexpr S s {}; Gcc 4.8 doesn't like this, telling me the forward-declaration and the definition differ in constexpr -ness. Is gcc speaking truth, or is this just a gcc bug? 回答1: I can't find any language in my copy of the C++11 standard that explicitly forbids constexpr -ness from mis-matching between