How do I do weak linking in Swift?

Seems like I’ve figured out what you can do I used NSClassFromString() to check if class is available on device, i.e. if NSClassFromString(“UIBlurEffect”) { let blur = UIBlurEffect(…) //… } else { //… } It’s needed to make UIKit.framework (or another corresponding framework) optional. If you create Swift-based application in XCode6-BetaX, all the frameworks wouldn’t … Read more

Why is there no multiple definition error when you define a class in a header file?

The one-definition rule (3.2, [basic.def.odr]) applies differently to classes and functions: 1 – No translation unit shall contain more than one definition of any variable, function, class type, enumeration type, or template. […] 4 – Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program […] … Read more

Disable AVX-optimized functions in glibc (LD_HWCAP_MASK, /etc/ld.so.nohwcap) for valgrind & gdb record

It looks like there is a nice workaround for this implemented in recent versions of glibc: a “tunables” feature that guides selection of optimized string functions. You can find a general overview of this feature here and the relevant code inside glibc in ifunc-impl-list.c. Here’s how I figured it out. First, I took the address … Read more

literal constant vs variable in math library

GCC can do constant folding for several standard-library functions. Obviously, if the function is folded at compile-time, there is no need for a run-time function call, so no need to link to libm. You could confirm this by taking a looking at the assembler that the compiler produces (using objdump or similar). I guess these … Read more

Undefined Reference To ‘cv::initModule_nonfree()’ In Android

My development environment is set up as follows: android-ndk-r10d (install path: D:\adt-bundle-windows-x86_64-20140702\android-ndk-r10d\) OpenCV-2.4.10-android-sdk (install path: D:\CODE\OpenCV-2.4.10-android-sdk\), Download link OpenCV-2.4.10 (install path: D:\CODE\OpenCV-2.4.10\), Download link Building the nonfree module We actually only need to copy a few files from OpenCV-2.4.10 source code to OpenCV-2.4.10-android-sdk, namely: Copy the nonfree folder from OpenCV-2.4.10\sources\modules\nonfree\include\opencv2\ to OpenCV-2.4.10-android-sdk\sdk\native\jni\include\opencv2. Create a folder … Read more

How to Embed/Link binary data into a Windows module

Right click the resource script (.rc file) Choose Import http://msdn.microsoft.com/en-us/library/saced6x2.aspx You can embed any “custom” file you want, as well as things like .bmps and stuff VisualStudio “knows” how to edit. Then you can access them with your framework’s resource functions like FindResource LoadResource etc… If you don’t have a resource script. Click Project Add … Read more