Skip to content

Cross Platform Guide

Shane Saxon edited this page Mar 12, 2018 · 8 revisions

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

Platforms:

  • MSW - Windows XP, 7, 8, 10 and Server
  • OSX - 10.8.5 or newer
  • Linux - CentOS, Red Hat and Ubuntu

*Android and iOS are planned and WebGL based viewer is under consideration.

Coders are encouraged to generate code that is easy to port and integrate by 3rd parties as an API library.


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.

Standard Types

  • Use the types that are defined in 'stdint.h', such as 'int64_t' or the shorthand type defines in 'nptypes.h' such as int64. This will prevent issues between MSW and Linux. Avoid using terms like 'long int', which can resut in either a 64bit or 32bit int, depending on platform.
Clone this wiki locally