Agnostic Library C Operating System

Is there a C library for operations such as file operations, obtaining system information, etc., which is shared, which can be used when compiling on different platforms and which behaves in a similar way?

Edit : something like a Java or .NET platform that abstracts hardware.

+6
c
source share
5 answers

Yes; ISO standard standard library. It may not cover all the features you want, but that is precisely because it is common, and as such is also the lowest common denominator. It only supports features that can reasonably be expected on most hardware, including embedded systems.

A way to approach this is to possibly indicate the range of target platforms that you need to support, and then the application domains (e.g., GUI, network connectivity, multithreading, image processing, file processing, etc.), and then select individual cross-platform libraries that meet your needs. There is probably no library to meet all your needs, and in some cases there is no shared library at all.

However, you will always be better served in this regard, hugging C ++, where you can use any C library, as well as C ++ libraries. The C ++ Standard Library is not only larger, but libraries such as Boost, wxWidgets, ACE also cover a wider range of domains. Another approach is to use a cross-platform language, such as Java, that solves the problem by abstracting the hardware into a virtual machine. Similarly, .NET / Mono and C # can provide a solution for a limited set of target platforms.

The following comment was added: The operating system provides hardware abstraction in the target language of the real machine (as opposed to a virtual machine language such as Java or CLR), so you may need a common operating system API. POSIX is probably closest to this, supporting Linux, Unix, OSX (Unix), QNX, VxWorks, BeOS, and many others; but not the main thing is Windows. One way to use POSIX on Windows is to use Cygwin. Another is to use a virtual machine to host a POSIX OS such as Linux.

+4
source share

Have you tried the standard library? It must be implemented in any system that has an ISO compatible runtime.

+10
source share

For anything not found in the standard library, GLib is a good first place to look at other libraries created to interact with it. It offers, for example, streams, mutexes, and IPCs that you cannot write portable using the standard standard libraries, and you can use many more GNU libraries that follow the same conventions as the full GUI in GTK +. GLib supports the usual popular operating systems.

+1
source share

If the standard C library is not enough for your needs, the smallest hyperportable subset of POSIX may be the goal for which you want to execute code. For example, the main operating system other than POSIX, Windows still has a number of functions with the same names as the POSIX functions, which behave quite close - open , read , write , etc.

Documenting what a "POSIX hyper-relocatable subset" includes, and which non-POSIX operating systems should fit that subset, is a moderately challenging task that would be very useful in itself to avoid food plague. " MyCompanyName Portable runtime, "which pops up again and again every few years and unnecessarily inflates popular software such as Firefox and Apache.

0
source share

If you need tools beyond what the Standard C library provides, check out the Apache Portable Runtime (APR). You should also check to see if POSIX supports the functionality you use, although it comes with its own worm pack.

If you want to get into graphics, etc., then you get into another world - GTK, Glib and Qt spring, although I did not use them.

0
source share

All Articles