Potential problems porting to different architectures

Posted by Brendan Long on Stack Overflow See other posts from Stack Overflow or by Brendan Long
Published on 2010-04-22T00:29:28Z Indexed on 2010/04/22 0:33 UTC
Read the original article Hit count: 220

Filed under:
|
|
|
|

I'm writing a Linux program that currently compiles and works fine on x86 and x86_64, and now I'm wondering if there's anything special I'll need to do to make it work on other architectures.

What I've heard is that for cross platform code I should:

  • Don't assume anything about the size of a pointer, int or size_t
  • Don't make assumptions about byte order (I don't do any bit shifting -- I assume gcc will optimize my power of two multiplication/division for me)
  • Don't use assembly blocks (obvious)
  • Make sure your libraries work (I'm using SQLite, libcurl and Boost, which all seem pretty cross-platform)

Is there anything else I need to worry about? I'm not currently targeting any other architectures, but I expect to support ARM at some point, and I figure I might as well make it work on any architecture if I can.

Also, regarding my second point about byte order, do I need to do anything special with text input? I read files with getline(), so it seems like that should be done automatically as well.

© Stack Overflow or respective owner

Related posts about c++

Related posts about gcc