Skip to content

Cross Platform Guide

Shane Saxon edited this page Aug 9, 2017 · 8 revisions

[Home] - also see: [Code_Style_Conventions] - hosted at openANTz.com

also see [Code_Style_Conventions]


Platforms:

  • MSW - Windows XP, 7, 8, 10 and Server
  • OSX - 10.8.5 or newer
  • Linux - CentOS, Red Hat, Fedora, Ubuntu, SUSE, Debian
  • *Android and iOS are planned, WebGL under consideration

ANTz is a cross-platform application written in C99 with support for 3rd party addons using C++, Python and JAVA.

Coders are encouraged to generate code that is easy to port to other platforms and be integrated as an API library.


Conventions:

  • Isolate OS specific code. All platform specific code and libraries are isolated in the 'sdk/src/os/' folder. The file '.../os/npos.h' serve as a re-direct for all OS specific methods. The actual OS specific code resides in a sub-folder for that OS, such as 'sdk/os/msw/npos.c' which where OS specific libraries are included, ie: 'windows.h'.

  • Create plugin(s) for platform specific functionality, such as a .dll (MSW), .dylib (OSX) and/or .so (Linux). Ideally, everything would be cross-platform, but all to often hardware or certain libraries are OS specific.

Issues:

Line Endings - CRLF(MSW), CR(OSX), LF(Linux)

  • CSV files need to be tolerant to all of the above.
  • Code files (.c and .h etc...) need an extra blank line return at end of file.

File Path - ''(MSW) vs '/'(OSX, Linux)

  • file path routines need to be OS aware and use appropriate slashes.
  • header include statements should always use a forward slash ("../io/npgl.h") as this works under all OS compilers (MSW, OSX, Linux.)

Visual Studio - is far too tolerant of bad code...

  • watch out for 'warning' followed by 'assuming' resulting from missing function declarations usually a headers issue.

Xcode - also too tolerant of non-C code...

  • allows C++ behavior in C files... avoid this.
  • declare all variables at the top of the function before any logic statements.

BIG ENDIAN vs little endian

  • watch out when doing any bitwise or bytewise operations.
  • be-aware of byte orders in communicating with other machines.

Global Variables

  • rather then use globals, it is preferred to store global-like variables in the main data structure, (data->...myVariable).
  • however, temporary use of globals to aid short-term development is okay, just do not initialize them when declared, as this has caused problems. Instead use one of the startup Init...() functions to initialize global variables.

Clone this wiki locally