E
E
evg_962018-08-21 13:24:34
C++ / C#
evg_96, 2018-08-21 13:24:34

How does the linker look for functions?

As I understand it, the function declaration is in the stdio.h file (Some kind of unusual function declaration)

_Check_return_opt_
_CRT_STDIO_INLINE int __CRTDECL printf(
    _In_z_ _Printf_format_string_ char const* const _Format,
    ...)

Where is the definition of the function? (Well, where is stdio.h locally).
At what stage in the program will the source code of the mentioned function be present? And in what form, already in binary, asm or in C?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
al_sh, 2018-08-21
@al_sh

source code will not be present. at the linking stage, the object code will be linked to the object code of your program. the printf object code is part of the c/c++ standard library libc/glibc

A
Antony, 2018-08-21
@RiseOfDeath

Almost certainly this is a function in a third-party lib and will twitch from it.
At least that's how it is usually implemented on Linux. I don't know how it works on Windows.

C
CityCat4, 2018-08-21
@CityCat4

I have a different definition :) - and I don’t know where you got this from.
Bucket 4.14.52, glibc 2.26-r7, Calculate Linux 17
Same - bucket 2.6.32-696, glibc 2.12, CentOS 6.10
Locally, stdio.h is located in the same place as everything else - in /usr/include. The source code of this function will never be present in the program. Generally. The stdio() code is in glibc, which is respectively in /lib64 (for 32-bit systems - in /lib). If you really want to look at its source - download the glibc source.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question