naveen yadav <yad.naveen@xxxxxxxxx> writes: > I checked that for fprintf() call if stream is other then stdout or > stderr then code flows comes to vfprintf() function and if stream is > stdout or stderr then code flow is different and fwrite() function is > getting called. Use gcc -fno-builtin-fprintf to disable this transformation. However, that option also makes GCC not warn about calls like fprintf(stdout, "hahaha%s\n") where the format string does not match the argument list. You can restore those warnings by declaring fprintf with __attribute__((format(printf, 2, 3))). <stdio.h> of glibc apparently does not do that. According to gcc/builtins.c (avoid_folding_inline_builtin), another way to disable the transformation would be to declare fprintf as an inline __attribute__((always_inline)) function. However, that causes an error if compiling with gcc -O2. If you only declare fprintf without a function body: In file included from test-builtin-fprintf.c:1:0: /usr/include/stdio.h:353:12: error: inlining failed in call to always_inline ‘fprintf’: function body not available test-builtin-fprintf.c:24:10: error: called from here If you define fprintf with a function body: In file included from test-builtin-fprintf.c:1:0: test-builtin-fprintf.c: In function ‘fprintf’: /usr/include/stdio.h:353:12: error: function ‘fprintf’ can never be inlined because it uses variable argument lists