Is it possible to run a written code or written library that only uses initial c libraries, on every platform?

For example: Windows, ARM Microprocessors, PIC microprocessors,

They have their compilers seperately and this difference is not important for me, I can compile in different compilers for need. But do I have to change code totally or partially to run on this platforms?

Note: For libraries, I will just use default c libraries.

有帮助吗?

解决方案 2

In embedded systems you will need to implement certain functions that the operating system gives you (like _sbrk, _read, etc.) for standard library functions like malloc and printf.

If you take care of that I don't see a reason for your code not to work so long as you take GREAT CARE in how you write it. By GREAT CARE, I mean be very careful with floating points, processor word size and any other things that are not common between your desired targets.

Short answer: possible, but not easy.

其他提示

It depends. If your library use only standard C and the multiplatform you are about to port has a compiler compatiable to standard C, you can always write the library code. But if your library have to call native API of each platform, you have to encapsulate these code seperately.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top