Compact 2013 Ebook

13.2 Native Code Apps
Created by djones on 6/18/2013 1:18:16 AM

Native Code Applications

Native application development for Windows Embedded Compact and Windows Embedded CE involves coding in C++, C and assembler. This code may or may not be platform specific but the compiler will be source code and CPU specific. The binary file generated by the compilation will only run on a platform that has the CPU targeted by that compiler (or a CPU from that family). For example, a simple ”Hello World” application compiled for an x86 CPU won’t run on an ARM CPU, although it may run on an x64[1] CPU. Such a simple application could be recompiled with an ARM compiler. If though the code addressed target specific resources such as hardware, that wouldn’t be the case.

The binary code generated by a compiler is specific to a CPU because the instructions contained within it exactly match the instruction set of the CPU. For example, a C++ code statement to store a value to a variable may be implemented in machine code as

(i) Store the value in a register,

(ii) Store the assigned address of the target in another register,

(iii) Store the first register value in the address specified by the contents of the second register.

The assembler code for the same functionality would be a textual representation of those machine instructions.

Whilst the outcome of a Native Code project is a binary file, it may be an executable, a dynamic link library (DLL) or a static library (LIB) file. A DLL is a library that is loaded when an application requires its resources and once loaded can be shared amongst other applications that require its resources. A static link library is a precompiled binary resource that is added to an application compiled code in the link phase of the application build. When an application that uses a DLL is compiled there is a “ghost” .lib that is linked to the compiled application that gives it the required meta-information about the DLL.

Code compilers may also be operating system or even operating system version specific. This applies to Windows Embedded Compact 2013 in that binaries from previous versions of the operating system (e.g. Compact 7) are precluded from running on a Compact ’13 system by the OS. Microsoft has indicated that applications from previous versions of the OS are source code compatible not binary compatible. The source code from earlier OS projects can be ported to Compact 2013 and recompiled there. Unfortunately, Visual Studio 2012 won’t upgrade the “`” projects from earlier versions of Windows Embedded Compact/CE.

When a Native Code application is implemented, use is made of various runtime libraries depending upon the application’s requirements. The Full C Runtime is linked into to all native applications and its operating system component is an automatic inclusion (an “Always-On” Catalog feature) in all Compact 2013 operating systems. A Native application would probably use the C Runtime (MSVCR) and may use the Standard C++ Library. The Standard Template Library (STL) is also available providing high level programming classes. Compact 2013 also supports the Active Template Library (ATL) for creating light weight COM components, and the Microsoft Foundation Class (MFC) library for heavier weight COM components including COM UI applications.

The Native Code improvements in Compact 2013 all are targeted at making the C++ compiler as close as possible to the desktop C++ compiler. To that end it implements much of the C++ 11 Standards. Some of the improvements with C++ are:

  • Lamda Functions
    • Unnamed inline functions that can be passed to other functions
  • Strongly typed and scoped enumeration support
    • Enum values scoped to enclosing enumeration,
    • Enum values not explicitly converted to integers
  • Ranged based loops
    • Foreach iterators with arrays and enums
  • “auto” keyword
    • Compiler assigned type depending upon initialization
  • Multi-core Improvements
    • Auto-vectorizer
    • Auto-parallelizer

Table 11: Compact 2013 C++ improvements

Note 1: Although the Compact 2013 C++ compiler runs on the desktop it is not the same executable as that used for the desktop applications as the Compact Win32 is not the desktop Win32.

Note 2: The OpenMP multithreading library has been removed from Compact 2013.

Note 3: A device driver is developed as a native code DLL with a specified interface.

Note 4: Windows Embedded Compact resources are stored as .libs that are linked together when you build your customized operating system. If you mistakenly do a full Sysgen you are actually rebuilding many of the OS .lib resources.


[1] Although a Compact 2013 x86 OS may run on an x64 CPU system, Windows Embedded Compact is a 32 bit operating system, not 64 bit.


NEXT: Managed Code Development

print

Click here to provide feedback and input

  Comments

There is no comment.

Turkish porno izle video site in rokettubeporno izle