How are all the c++ functions finally defined? [closed]

for example, we know that printf() function displays text in the console screen. But how are functions like printf() defined. Is it possible to write code to display text without the use of <strong>any</strong> library files? is assembly code used in defining these functions?


We can talk about C more easily, because it's a very basic language and really a little more higher over asm. The answer is: <strong>system calls</strong>. You could wonder: why? There are things that a language cannot do. And I/O is one of those. I/O streams are "owned" by the Operating System. It handles them. The OS allows you to use them, but you must always rely on it before.

System calls are very basic: there are no format strings or whatever, for example. Also you need to consider that system calls are OS-dependent. Windows' ones are different from Linux's ones.

puts implementation in the glibc


Since every library/code internally use the operating system calls provided by kernel. So, It is possible to write your own printf like function without using c library.

If you want to know how these functions internally works, you can go for assembly language programming.


Is it possible to write code to display text without the use of any library files?

Yes of course it is. You might directly drive your display device, without any use of the standard functions.

is assembly code used in defining these functions?

Not necessarily, it can be completely accomplished in c or c++, without a single line of assembler code.

In the end it depends on the actual toolchain you are using to compile your programs, and the standard libraries that come with it, how these functions are defined. There are certain low level functions, you can 'override' for your concrete environment.

A common binding is to map the standard output interface (as used by printf()) to one of the UART interfaces of a MCU.

E.g for the commonly used newlib(c) coming with GCC toolchains here's some reference what's necessarily has to, and optionally can be ported to any environment: 'What steps do I need to do to port newlib to a new platform?'


Is it possible to write code to display text without the use of any library files?

Absolutely, since they have also done it, haven't they?

You would need to interface your kernel for writing low-level libraries like that, albeit it is not strictly necessary for each single case.

is assembly code used in defining these functions?

Yes, partially, using SIMD alike and other clever tricks for performance critical parts, etc.


  • Why does calling next on an Iterator trait object give me an “out of memory” at runtime?
  • Why does PostgresSQL reassign role command, change template database's owner
  • How can I get all open graph pages owned by an application?
  • Git subtree post hook
  • How to create a data template dependent on an XML Attribute?
  • Validity Method for Reference Classes
  • How do I recognize a line break with a switch case that evaluates a char in Java?
  • Difference between two forms of Perl filename wildcard command
  • Jquery resizable reposition handle after scroll
  • Is there a way to link a linux's thread TID and a pthread_t “thread ID”
  • Create a multiple screen android application
  • Does the Azure table storage API cache results?
  • 'doc_del_count' bigger than 'doc_count' on CouchDB
  • Oracle - Second level subquery cannot see field from main query
  • A class implementing two different IObservables?
  • several dataProvider per one Test in TestNG
  • How can I get the full list of running processes on a Mac from a python app
  • Jquery Knockout: ko.computed() vs classic function?
  • cordova is not defined - cordova.js has already been loaded :: Ionic
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • Overlapping controls in Windows XP
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • Sony Xperia Z Tablet not found by adb
  • Obtain ObjectIdHex value from mgo query
  • Java applet as stand-alone Windows application?
  • Javascript convert timezone issue
  • When should I choose bucket sort over other sorting algorithms?
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Font Awesome Showing Box instead of Icons
  • How do you troubleshoot character encoding problems?
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Apache 2.4 - remove | delete | uninstall
  • WOWZA + RTMP + HTML5 Playback?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Cannot Parse HTML Data Using Android / JSOUP
  • How do you join a server to an Active Directory (domain)?
  • Understanding cpu registers
  • Is it possible to post an object from jquery to bottle.py?
  • Python/Django TangoWithDjango Models and Databases