Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C library vs WinApi

Many of the standard c library (fwrite, memset, malloc) functions have direct equivalents in the Windows Api (WriteFile, FillMemory/ ZeroMemory, GlobalAlloc).

Apart from portability issues, what should be used, the CLIB or Windows API functions?

Will the C functions call the Windows Api functions or is it the other way around?

like image 469
Joao Vilaca Avatar asked Jan 12 '09 00:01

Joao Vilaca


People also ask

What is WinAPI in C?

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems.

Is Win32 a library?

The Win32-common library provides a define callback macro to make it easy to define callback functions without the application programmer needing to use the FFI define c-callable-wrapper macro directly.

Is WinAPI C or C++?

Most Win Api is C. There are couple exceptions (dor example COM IFAIR). But almost every code in MSDN says C++..

What is the C runtime library?

The C runtime Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C standard library. The Visual C++ libraries that implement the CRT support native code development, and both mixed native and managed code. All versions of the CRT support multi-threaded development.


2 Answers

There's nothing magical about the C library. It's just a standardized API for accessing common services from the OS. That means it's implemented on top of the OS, using the API's provided by the OS.

Use whichever makes sense in your situation. The C library is portable, Win32 isn't. On the other hand, Win32 is often more flexible, and exposes more functionality.

like image 154
jalf Avatar answered Sep 23 '22 13:09

jalf


Will the C functions call the winapi functions or is it the other way around?

The C functions (which are implemented in a user-mode library) call the WINAPI functions (which are implemented in the O/S kernel).

like image 40
ChrisW Avatar answered Sep 25 '22 13:09

ChrisW