40media Potential problems porting to different architectures
صفحه اصلي

Potential problems porting to different architectures

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.

Check linux distro name


Accessing global variable in multithreaded Tomcat server
In my experience, once code works well on a couple architectures, it will port more easily to a third one. Killing HTML nodes from shell Input shouldn't be an issue. Remote debug a linux app from XCode Structure alignment may be an issue if you did anything where alignment is an issue.. Test for external undefined references in Linux Pay attention to anything this might be platform-dependent: relying on bitfields being aligned the same way, assuming variables are a particular size, etc. Problem when compressing SWF in Linux with java.util.zip If your code is relatively abstract from the hardware, you will likely encounter few problems. linux (centos) privilege to copy file If you are doing any thing with any thing like networking code, you will have to make sure you align with netjob byte rule properly.. How do I compile on linux to share with all distributions? I have ported device drivers from PPC to x86, and then to x86_64; in a few thousand lines, there were maybe a couple changes, primarily related to structure and integer ordering.. The only way to know for sure is to try it, of course..

50 out of 100 based on 55 user ratings 610 reviews