Search code examples
c++apiabi

API AND ABI in a nutshell


please can't figure out what is an API and an ABI in simple words (no wikipedia definitions please) , are they a part of the kernel ? are they functions ? what do they do ?


Solution

  • An API is an application programming interface. It provides a way for different source-level software components to communicate with each other.

    An example of an API would be a header file for a library, which specifies a set of functions provided by the library and how to call them. For example, in C++:

    //external_library.h
    //Processes your data and writes the results to outputlog.txt
    void ProcessMyData (std::string data);
    

    This tells a programmer using external_library that they can call a function called ProcessMyData. This function takes in a std::string, returns nothing, and (if the documentation is up-to-date) writes the results to outputlog.txt.


    An ABI is an application binary interface. It provides a standard way for binary components to communicate with both the platform and each other.

    An example of an ABI would be the System V ABI. This specifies various details such as function calling conventions, binary data representations, object file formats, loading, linking, etc. You can read a draft of the SysV ABI for AMD64 processors here to get an idea of its contents.