Cross-Platform Compatibility Mode

Cross-Platform Compatibility Mode (CPM) is a a special mode of the compiler than can be activated (per project or per individual file) that makes the compiler more lenient towards platform differences and makes it easier to write sharable code.

In essence, in CPM the compiler will be less strict in enforcing "clean" code for the current platform, in exchange for allowing you to write code that will work, without or with fewer IFDEFs, on all platforms. It will also emit additional errors and warnings for code patterns that are not suitable for cross-platform sharing.

More Leniency

The compiler will be lenient and allow the following, which normally would result in errors or warnings:

  • Identifiers where the case of the first letter is mismatched (.ToString vs .toString()).
  • Mismatched casing in namespaces (which are generally all lowercase in Java, and PascalCased for .NET and Cocoa).

Case mismatches would otherwise of course be errors in C# and Swift, and optionally emit a warning when the "Warn on Case Mismatch" option is turned on in Oxygene.

Additional Warnings

In addition, the compiler will emit warnings when using any of the following features, which are not available on all platforms, because using them will make the code inherently not cross-platform.

  • Use of BigInteger constants
  • Use of function pointers
  • Use of selector (Oxygene) or __selector (C#) syntax
  • Use of the Auto-Release Pool syntax
  • Use of the unsafe keyword and unsafe code
  • Use of the raises keyword in Oxygene (supported on Java only)
  • Use of the Optional attribute on interface members (supported on Cocoa only)
  • Use of parallel, and queryable sequence (supported on .NET only)
  • Use of the interlocked*() APIs (supported on .NET and Cocoa only)
  • Direct calls to init.alloc instead of a constructor (supported on Cocoa only)
  • Use of function, method, procedure pointers, which differ between .NET/Java vs. Cocoa

These warnings will be emitted for any code compiled in Cross-Platform mode that is not surrounded by IFDEFs for a specific platform.

See Also