-
Notifications
You must be signed in to change notification settings - Fork 216
Portability Gotchas
Ryan Pavlik edited this page Mar 3, 2015
·
1 revision
VRPN builds and runs on a wide array of platforms and compilers. Here are some "gotchas" you might want to be aware of if you're writing code to go in VRPN.
- In general, Visual Studio implicitly includes more headers than other compilers, so if it builds in VS, it still may be missing headers. Include what you use.
-
defined(_WIN32)
is the correct check to put around code that only makes sense on Windows. -
defined(_MSC_VER)
is the correct define to check if we're building with Visual Studio.- Corollary:
defined(_WIN32)
does not implydefined(_MSC_VER)
- there are other compilers and cross-compilers.
- Corollary:
-
snprintf
is not available in older Visual Studio versions (2008?) so can't be used at the time being. TODO: Figure out a suitable solution.
- Byte order varies between machines. Always use the
hton
/ntoh
functions VRPN provides if you're putting data on the network on your own. - On a related note, though USB data is often little-endian just like your desktop, that doesn't mean
memcpy
works everywhere to load USB data. Usevrpn_unbuffer_from_little_endian
-
M_PI
isn't in the C++ or C standard. It's a POSIX thing. TODO: Figure out what the solution is, without involving definingM_PI
in lots of source files.