I have been reading statement in a lot of books/links like - "There are many factors which determine the porting of c code from one platform to other".Are the platform they refer OS or microprocessor.What are these factors on which porting of code from one platform to the other depends on. Thank you in advance.
Platform probably refers to OS + compiler + virtual memory address space + underlying HW architecture.
Some of the factors are:
The API provided by the OS for dynamic memory allocation, thread synchronization, shared resource protection, etc.
The size of primitive types, which is determined by the compiler (except for sizeof(char)
which is 1 by the C-language standard).
The size of pointers, which depends on the size of the virtual memory address space (4 bytes on 32-bit platforms and 8 bytes on 64-bit platforms).
The endian-ness of the underlying HW architecture, which yields different behavior when accessing types larger than char
via "raw address" (e.g., using char*
).