Reputation: 205
I read that the stdio.h header file contains function declarations (with prototypes), macro definitions and definitions of data types. But when I opened the file in VSCode it contained function definitions too — not sure if they are definitions or something else. Please explain the following. What is this code doing? More importantly, is it function definition?
mingw_stdio_redirect
int fprintf (FILE *__stream, const char *__format, ...)
{
register int __retval;
__builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
__retval = __mingw_vfprintf( __stream, __format, __local_argv );
__builtin_va_end( __local_argv );
return __retval;
}
mingw_stdio_redirect
int printf (const char *__format, ...)
{
register int __retval;
__builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
__retval = __mingw_vprintf( __format, __local_argv );
__builtin_va_end( __local_argv );
return __retval;
}
Upvotes: 2
Views: 926
Reputation: 1184
Probably you should add the complete function definition as supposed to be from MinGW
which appears to be:
__mingw_ovr
__attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
int printf (const char *__format, ...)
{
register int __retval;
__builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
__retval = __mingw_vprintf( __format, __local_argv );
__builtin_va_end( __local_argv );
return __retval;
}
which is is found quite different from the original GNU
stdio.h
found here :
https://code.woboq.org/userspace/glibc/libio/stdio.h.html
Either way mingw looks like it has function definitions in header file. And if you look at
#define __mingw_ovr static __attribute__ ((__unused__)) __inline__ __cdecl
what __mingw_ovr
is it - it appears that is an inline
function.
Upvotes: 1
Reputation: 825
The code you have quoted appears to be definitions of functions.
Header files that you create should contain only
Later (once your C skills have advanced somewhat) you might also include
inline
functionsA compiler implementer, on the other hand, may put anything they like in their header files, as long as their compiler behaves the way the language standard says it must. You should rely only on the compiler's documentation, and not on anything you might intuit from reading other files supplied with the compiler, to understand its behaviour.
A compiler implementer is permitted to use any magic they choose, including having the compiler Just Know what the system headers are required by the Standard to define and declare without any actual files for those headers, and if they so choose they may even provide "header" files containing bogus or misleading contents.
Upvotes: 2
Reputation: 1724
According to C-language standard draft
7.21 Input/output
7.21.1
Introduction
1 The header defines several macros, and declares three types and many functions for performing input and output.
2 The types declared are size_t (described in 7.19);
Link -> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf (page - 314)
As for what the code is doing: It prints formatted data to the stream.
Upvotes: -1