univint

From Lazarus wiki
Logo OSX.png

This article applies to macOS only.

See also: Multiplatform Programming Guide

Overview

The univint package contains Pascal translations of various Mac OS X framework headers.

In FPC 2.4.0 and earlier, these headers are only available for PowerPC and Intel 32 bit. Most headers in these versions are limited to their state in Mac OS X 10.1, although some are newer (a few have even been updated to Mac OS X 10.5).

In later FPC versions, they are also available for 64 bit platforms and for iOS/ARM, and have been updated to Mac OS X 10.6. Since not all APIs are available to 64 bit and iOS applications in the C headers, the same is of course true for the Pascal translation.

See Apple's documentation for details about which APIs are available on which platforms.

Carbon framework

The Carbon framework is not available at all on the iOS platform, is only partially available on 64 bit macOS platforms up to macOS 10.14 Mojave, and is not available at all on the forthcoming macOS 10.15 Catalina due towards the end of 2019. Catalina has dropped support for all 32 bit applications - they will not execute. The future for macOS is the 64 bit Cocoa framework.

Therefore, while on 32 bit platforms the MacOSAll unit contains a {$linkframework Carbon} statement so that any program using that unit automatically links in the Carbon framework, we have opted not to do this for 64 bit platforms. On those platforms, the MacOSAll unit will by default only link against the CoreFoundation framework. If you wish to use Carbon functionality from a 64 bit application, you must explicitly link it in by adding the aforementioned statement to your program.

A side-effect of this policy is that the the GetKeys routine is not available in the 64 bit version of MacOSAll. The reason is that this function is implemented using a wrapper, which in turn calls the real GetKeys routine from the Carbon framework. As a result, if smart linking/dead code stripping is not enabled, then the presence of this wrapper in your program (via the MacOSAll unit) makes your program depend on the Carbon framework, which as mentioned above is not very nice for 64 bit programs. Therefore this one function is available in a separate unit called KeyEvents when compiling for 64 bit. For 32 bit programs, this unit also exists, but is empty (simply to avoid requiring ifdefs in case you need this routine in 64 bit).