clang

mktime Only Handling Leap Years on Clang?

元气小坏坏 提交于 2019-12-24 15:21:29
问题 In this answer I proposed that marihikari use the standard functionality of mktime rather than trying to implement his own Gregorian calendar system. I wrote this function to demonstrate how mktime could be used to accomplish this: bool leap_year(int year) { tm bar = { 0, 0, 0, 29, 1, year - 1900 }; mktime(&bar); return bar.tm_mday == 29 && bar.tm_mon == 1 && bar.tm_year == year - 1900; } Testing this with: cout << "2000: " << leap_year(2000) << "\n2001: " << leap_year(2001) << "\n2004: " <<

This hash only works for enumeration types

会有一股神秘感。 提交于 2019-12-24 14:25:28
问题 I'm working on a (very) simple class in C++ that has a unordered_map member: class SDLFontManager : public CPObject, public FontManagerProtocol { public: SDLFontManager() {}; // flush the cache when the manager is destroyed virtual ~SDLFontManager() { flushFontCache(); }; // load a font from the cache if it exists, or load it from file and cache it. virtual FontProtocol* fontWithTTF(const char* filename) { if(_cache.find(filename) != _cache.end()) { return _cache[filename]; } SDLFont* font =

Are there any “moving target” alias-values for GCC or Clang `-std=`, implying “use the latest standard”?

一曲冷凌霜 提交于 2019-12-24 13:45:07
问题 I'd like to create shell aliases that will always use the "latest" version of the C/C++ standards supported by gcc / g++ / clang / clang++ (one alias for C, one alias for C++). I realize that this could have multiple interpretations: The latest GNU-extended standard The latest released standard (e.g. C++14) The latest unreleased standard (e.g. C++1z) The latest standard fully implemented by the compiler (e.g. C++11 for GCC 4.9, C++14 for GCC 5+) ... possibly other options I haven't thought of

Why can .c files contain blocks?

ぃ、小莉子 提交于 2019-12-24 13:42:48
问题 I think block is the Objective-C feature. Recently I am adding the block to some C source file and I found it just compile OK. I get confused, for *.c file, should the compiler(Clang) consider it as the pure C file, why it can permit block? 回答1: Actually Clang introduces blocks to C and, by extension, Objective-C, C++, and Objective-C++ As you can read here in the overview. Of course, using blocks makes your source incompatible with C11 standard but, you know, as long as your code is for Mac

Clang+VS2013: error when including c++ header (vs2012:working)

。_饼干妹妹 提交于 2019-12-24 12:20:38
问题 Edit i found http://llvm.org/docs/GettingStartedVS.html Because of this, clang cannot parse the C++ standard library included with Visual Studio, nor parts of the Windows Platform SDK. So, if C++ is not supported with Visual Studio headers, should i still write a bug report? Q: I installed the clang visual studio toolchain from http://llvm.org/builds/. Using VS2013, i get several errors when compiling any c++ header. For example: #include <memory> int main() { return 0; } These errors seem to

Clang equivalent of GCC's __builtin_darn()

こ雲淡風輕ζ 提交于 2019-12-24 11:46:58
问题 I'm trying to discover Clang's equivalent to GCC's __builtin_darn() on Power9. Grepping Clang 7.0 sources it looks like LLVM supports it: llvm_source$ cat llvm/test/MC/PowerPC/ppc64-encoding.s | grep darn -B 1 -A 1 # CHECK-BE: darn 2, 3 # encoding: [0x7c,0x43,0x05,0xe6] # CHECK-LE: darn 2, 3 # encoding: [0xe6,0x05,0x43,0x7c] darn 2, 3 However, I can't seen to find the builtin: llvm_source$ grep -IR darn | grep builtin llvm_source$ What is Clang equivalent of GCC's __builtin_darn() ? 回答1: You

How can I parse a typedef for a function pointer using clang API to get the function pointer name?

徘徊边缘 提交于 2019-12-24 11:29:05
问题 I am currently building a parser for C++ code using the clang C API. The parser will process a header file and generate a list of defined and missing symbols for it (it ignores include directives, so it will parse strictly the contents of the header). My problem is, if I have a typedef for a function pointer which takes an argument of an undefined type, such as: typedef SOME_TYPE (* funcPtrName)(SOME_UNDEF_TYPE x); the AST parses SOME_TYPE as the typedef instead of funcPtrName . If I replace

Linking Boost with cmake and clang - undefined reference to symbol

杀马特。学长 韩版系。学妹 提交于 2019-12-24 10:29:29
问题 In my C++ program, I am including boost's filesystem and regex headers and eventually thread support. I would like cmake and clang to link against them during build time. I am receiving the following error: [100%] Building CXX object CMakeFiles/a.out.dir/src/main.cpp.o Linking CXX executable a.out /usr/bin/ld: CMakeFiles/a.out.dir/src/main.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/libboost_system.so.1.56.0: error adding symbols: DSO missing from

How to intall Clang 9 on Mac?

女生的网名这么多〃 提交于 2019-12-24 10:25:32
问题 Here's what I have on my Mac: clang --version Apple LLVM version 10.0.0 (clang-1000.10.44.4) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin my app needs to be compiled with clang version 9, how can I install it on my Mac? I went to LLVM official site, but I don't see Clang 9 there. Any help is greatly appreciated! 回答1: I downloaded Xcode 9.2 and then did xcode-select -s /Applications/Xcode.app/Contents/Developer and then my

Preparing for CRAN: '-fopenmp' clang error?

早过忘川 提交于 2019-12-24 09:58:32
问题 I am preparing a package (which makes use of Rcpp and RcppArmadillo) for submission to CRAN. I am using Travis CI and I have included the following to test my package more thoroughly: os: - linux - osx compiler: - clang - gcc This, however, yields the (familiar, it seems) error when using clang on OS X * installing *source* package ‘my_pkg’ ... ** libs clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"/Users/travis/R/Library/Rcpp/include" -I"/Users/travis/R/Library