compile-time

Speed up Xcode Swift build times

一笑奈何 提交于 2019-12-20 10:46:37
问题 As my project has grown over the past year, so have its build times. Over the last few months it's gone from 4 minutes to around 7 (time includes GitHub pull, unit tests, etc). I have investigated with -Xfrontend -debug-time-function-bodies to find lines that are slow to compile, and changed that code. I believe it's now a question of project size; 182 Swift files, ≈31K lines. 23 storyboards, 52 XIBs. This is a regular UIKit app with a handful of Cocoapods dependencies. The bulk of the build

How do I output a compile-time numeric constant during compilation in Visual C++?

自古美人都是妖i 提交于 2019-12-19 07:07:10
问题 Visual C++ has #pragma message that outputs a string into compiler output. Now I have a factory: template<class Type> CComPtr<Type> CreateComObject() { CComPtr<Type> newObject( new CComObject<Type> ); //do some tuning to the object return newObject; } and I want to output the size of class that is passed to new (namely sizeof( CComObject<Type> ) into the compiler output. Looks like #pragma message only accepts strings. How can I output a compile-time numeric constant? 回答1: If I understood

sizeof(value) vs sizeof(type)?

久未见 提交于 2019-12-18 17:28:05
问题 Considering : double data; double array[10]; std::vector<int> vec(4, 100); MyClass myclass; Is there a difference between : sizeof(double); sizeof(double[10]); sizeof(std::vector<int>); sizeof(MyClass); and sizeof(data); sizeof(array); sizeof(vec); sizeof(myclass); Are the two syntaxes different or strictly equivalent ? Are all of them evaluated at compile-time ? If not, which one is evaluated at run-time ? 回答1: The only differences are in syntax and convenience. Syntactically, you're allowed

Scala - Enforcing size of Vector at compile time

。_饼干妹妹 提交于 2019-12-18 15:11:44
问题 Is it possible to enforce the size of a Vector passed in to a method at compile time? I want to model an n-dimensional Euclidean space using a collection of points in the space that looks something like this (this is what I have now): case class EuclideanPoint(coordinates: Vector[Double]) { def distanceTo(desination: EuclieanPoint): Double = ??? } If I have a coordinate that is created via EuclideanPoint(Vector(1, 0, 0)) , it is a 3D Euclidean point. Given that, I want to make sure the

Scala - Enforcing size of Vector at compile time

做~自己de王妃 提交于 2019-12-18 15:11:28
问题 Is it possible to enforce the size of a Vector passed in to a method at compile time? I want to model an n-dimensional Euclidean space using a collection of points in the space that looks something like this (this is what I have now): case class EuclideanPoint(coordinates: Vector[Double]) { def distanceTo(desination: EuclieanPoint): Double = ??? } If I have a coordinate that is created via EuclideanPoint(Vector(1, 0, 0)) , it is a 3D Euclidean point. Given that, I want to make sure the

Check for framework's existence at compile time?

大兔子大兔子 提交于 2019-12-18 12:14:42
问题 I'm working on an open-source project that can optionally use a closed-source framework. If the closed-source framework is included in the project, there will be additional functionality. But if the framework isn't included in the project, the project should still compile properly. How do I check at compile-time if the framework is included in the project? Basically, I want to do something like this: #ifdef _MY_FRAMEWORK_EXISTS #import <MyFramework/MyFramework.h> #endif I've seen older

run-time vs. compile-time iPhone version check

别等时光非礼了梦想. 提交于 2019-12-18 04:12:37
问题 What's the difference between run-time, e.g., [[UIDevice currentDevice] systemVersion] , and compile-time, e.g., __IPHONE_OS_VERSION_MIN_REQUIRED checking? When should you one over the other? Is __IPHONE_OS_VERSION_MIN_REQUIRED just a variable set in Build Settings? I've read the answers to How to target a specific iPhone version? and other related questions listed below. But, I just noticed that __IPHONE_OS_VERSION_MIN_REQUIRED = 30200 when I build & run on iPhone (4.3.1) with Xcode 4. Why?

Is static_cast<T>(…) compile-time or run-time?

北城以北 提交于 2019-12-18 03:58:18
问题 Is static_cast<T>(...) something that gets done at compile-time or run-time? I've googled around but I got different answers. Also, dynamic_cast<T>(...) is obviously runtime - but what about reinterpret_cast<T>(...) ? 回答1: Depends on what you are casting to what else. E.g. static_cast<std::string>("Hello") ends up calling std::string constructor. Off the top of my head, I can't think of any case where reinterpret_cast would need to generate actual machine instructions. It's just telling the

Implementing a compile-time “static-if” logic for different string types in a container

谁说胖子不能爱 提交于 2019-12-18 01:06:11
问题 I'd like to write a function template that operates on a container of strings, for example a std::vector . I'd like to support both CString and std::wstring with the same template function. The problem is that CString and wstring have different interfaces, for example to get the "length" of a CString , you call the GetLength() method, instead for wstring you call size() or length() . If we had a "static if" feature in C++, I could write something like: template <typename ContainerOfStrings>

Encrypting / obfuscating a string literal at compile-time

别说谁变了你拦得住时间么 提交于 2019-12-17 22:51:27
问题 I want to encrypt/encode a string at compile time so that the original string does not appear in the compiled executable. I've seen several examples but they can't take a string literal as argument. See the following example: template<char c> struct add_three { enum { value = c+3 }; }; template <char... Chars> struct EncryptCharsA { static const char value[sizeof...(Chars) + 1]; }; template<char... Chars> char const EncryptCharsA<Chars...>::value[sizeof...(Chars) + 1] = { add_three<Chars>: