Differences between Windows and Mac OS X

From Appmethod Topics
Jump to: navigation, search

Go Up to Considerations for Multi-Device Applications

When starting multi-device development for Mac OS X, you need to understand and be able to handle many issues, including the issues described here.

Exception Handling Is Different

Mac and Linux systems use Program Counter (PC)-mapped exceptions, whereas Windows (Win32) uses registration records linked on the stack.

You need to adapt your exception handling to the type used on your target platform. In particular, there are differences in the way assembly routines might need to be coded, if it is possible that an exception could be thrown past them. For more information, see PC-Mapped Exceptions#Unwinding Assembly Routines.

On the Mac OS X platform, structured exception handling (__try/__except) is not available. For more information, see Mac OS X Application Development#Exception Handling.

For general information about exception handling, see:

Alignment Differences between Mac and Windows

  • Alignment issues pertain only to development using Assembler code.
  • A Mac application binary uses 16-byte intervals.
  • The SO (shared object) stack must contain units of 16 bytes.
  • The Mac environment kills any process that does not match the 16-byte alignment.
  • See Eli's blog about the stack on Mac: http://blogs.embarcadero.com/eboling/2009/10/13/5620
  • WideChar vs. wchar_t (wchar_t is 2 bytes on Windows vs. 4 bytes on OS X)
  • tchar.h does not work on a Mac

Two Object Pascal compiler directives control alignment:

Accessing Global Variables in ASM on Windows and OS X

On OS X, global variables are addressed using position independent code (PIC), and this affects your ability to access globals in ASM.

If you have declared a global variable like this:

  GlobalVar: UInt32 = $12345678;

Then you expect to get the VALUE of this variable in ASM code like this:

function GetGlobalVar: UInt32;
  mov eax,[GlobalVar]

However, this code works correctly (as expected) on both Windows and OS X only if the global variable is declared in the SAME unit as the ASM routine. If GlobalVar resides in a different unit, then GetGlobalVar behaves differently on Windows and OS X:

  • On Windows, GetGlobalVar returns the VALUE of GlobalVar (as expected).
  • On OSX, GetGlobalVar returns the ADDRESS of GlobalVar (this can have problematic consequences).

To access a global variable, we recommend that you do the following:

function GetGlobalVar: UInt32;
    MOV EAX, [EBX].OFFSET GlobalVar
    MOV EAX, [EAX]

The initial 'begin' clause is needed to set up the required PIC prologue code that sets up EBX for this operation.

Windows Libraries Are Only Available to Windows Applications

Keep in mind these differences:

  • A Mac OS X application can call either FireMonkey APIs or POSIX APIs.
  • A Mac OS X application cannot call Windows APIs (neither 32-bit nor 64-bit).
  • A Windows application can be enabled to call either 32-bit Windows or 64-bit Windows APIs.

Equivalent File Extensions on the Mac and on Windows

Mac File Extension Windows File Extension
.o (object file)
.obj (object file)
.dylib (dynamic library)
.dll (dynamically linked library)

Equivalent Command-Line Elements on the Mac and on Windows

Element On the Mac On Windows

Command-line interface

Apple Terminal window (UNIX-based)

cmd Window (Start | cmd)

Command prompt


To reference the current directory, start your command with ./.


Directory list command


Change directory command

  • cd ..
    (move up one level)
  • cd directory
    (move to the specified directory)
  • cd ..
    (move up one level)
  • cd directory
    (move to the specified directory)

File-name separator


See Also