Skip to content

Cross Platform Guide

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

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.

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

Conventions:

  • OS specific core code is isolated in the 'sdk/src/os/' folder.
  • 3rd party platform specific functionality should be supported using a plugin. Such as a .dll (MSW), .dylib (OSX) and/or .so (Linux).
  • Also see Code Style Conventions

*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'.

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 Paths are OS specific

  • Use the Unix style forward slash '/' in paths, (MSW is tolerant in almost all cases.)
  • Header include statements should use a forward slash, this seems to work under all OS types, ie: "../io/npgl.h")

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

  • Watch out for 'warning' followed by 'assuming' resulting from missing function declarations, often a header 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.
  • Pay attention to byte orders in network communications.

Global Variables

  • Rather then use globals, it is preferred to store global-like variables in the main data structure, (data->...myVariable).
  • 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 a startup Init...() function to set global variables.

Clone this wiki locally