Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What in C++ can make Windows 8 apps not run on ARM?

Building a Windows 8 app, developers can choose HTML/JavaScript, XAML/.Net (C#/VB), and XAML/C++. I want to write my app in XAML/C++.

Building applications in the first two choices almost guarantees that your application will execute on both Intel and ARM architectures.

But I have heard that if I do certain things in my C++ app, I can cause the application NOT to execute on the ARM architecture. But I don't know the details.

Does anyone know what C++ Windows 8 apps should avoid so that they can run on ARM okay? Are these architecture decision or just differences in technique?

like image 643
Jerry Nixon Avatar asked Oct 22 '12 17:10

Jerry Nixon


People also ask

Can x86 applications run on ARM?

PCs powered by Arm provide great application compatibility and allow you to run your existing unmodified x86 win32 applications. Arm apps run natively without any emulation, while x86 amnd x64 apps run under emulation on Arm devices.

Can Windows run on ARM processor?

The core Windows on Arm experience, such as the Start Menu and File Explorer, are all compiled for and run natively on Arm chips, ensuring maximum performance. That is to say, they run directly on the processor with no need for translation, emulation, or any other middle layer, just like they do on an x86 PC.


2 Answers

In order to run on each architecture you first need to compile for each architecture obviously. If you write standard C++ (and if you do not rely on undefined behaviour and/or platform specific behaviour) you are fine the things that usually cause troubles when porting between architectures is:

(this list is an example)

  • sizes of int, long, long long (and others) can differ between platforms
  • signedness of char
  • how structures are padded
  • binary layout of floats
  • endianess
  • and more so on.

Usually you are safe if you refrain from crazy pointer arithmetic and casting.

like image 130
mauve Avatar answered Oct 12 '22 00:10

mauve


I'm not aware of anything that will make your code simply not execute or compile under ARM (other than inlining assembly).

However, there are things you can do which will make ARM give the wrong answer.

ARM processors are "weakly-ordered" this recent article gives you the low down

http://preshing.com/20121019/this-is-why-they-call-it-a-weakly-ordered-cpu

But to sum up, ARM processors may reorder memory accesses, and if you aren't careful, this can give you different results between x86 and ARM architectures in multi-threaded applications.

like image 23
OmnipotentEntity Avatar answered Oct 12 '22 00:10

OmnipotentEntity