Date: Fri, 01 May 2026 09:22:45 -0700
On Friday, 1 May 2026 00:39:01 Pacific Daylight Time Frederick Virchanza Gotham
via Std-Proposals wrote:
> Not sure why you're making this point, because the address of 'printf' gets
> resolved in C++, not in assembler, and so the compiler handles the
> mangling. We don't need to know the mangled name of printf.
printf is a macro.
$ cat test.cpp
#define __WINPTHREAD_ENABLE_WRAP_API
#include <pthread.h>
printf(xxxx)
$ x86_64-w64-mingw32-gcc -E test.cpp | tail -1
(pthread_testcancel(), printf(xxxxx))
But you missed the main point of the question: why would the Standard ever let
you intercept such functions?
> Jonathan:
> > How does 'goto -> std::printf' work with different
> > target function signatures?
>
> Because you can do something like:
>
> switch ( some_global_variable )
> {
> case 0: goto -> std::printf ;
> case 1: goto -> boost::printf; // perhaps has a different signature
> case 2: goto -> my_own_printf;
> }
And why would you want to do something like that? Why is a different signature
not a problem?
BTW, have you looked at GCC's __builtin_apply_args and __builtin_apply?
https://godbolt.org/z/9f1GMnG74
> A fourth use case is recreational hacking but I don't know if that counts
> standards-wise.
I don't think any of the use-cases count Standards-wise.
Don't get me wrong, I think the feature is useful... as an extension. And
probably with different syntax. It's pretty easy to do this with LD_PRELOAD
already for the 99% case where you do know what the arguments to the functions
are.
I don't think we need a Standards feature that is going to cater for the 1 use
per year on the entire planet.
via Std-Proposals wrote:
> Not sure why you're making this point, because the address of 'printf' gets
> resolved in C++, not in assembler, and so the compiler handles the
> mangling. We don't need to know the mangled name of printf.
printf is a macro.
$ cat test.cpp
#define __WINPTHREAD_ENABLE_WRAP_API
#include <pthread.h>
printf(xxxx)
$ x86_64-w64-mingw32-gcc -E test.cpp | tail -1
(pthread_testcancel(), printf(xxxxx))
But you missed the main point of the question: why would the Standard ever let
you intercept such functions?
> Jonathan:
> > How does 'goto -> std::printf' work with different
> > target function signatures?
>
> Because you can do something like:
>
> switch ( some_global_variable )
> {
> case 0: goto -> std::printf ;
> case 1: goto -> boost::printf; // perhaps has a different signature
> case 2: goto -> my_own_printf;
> }
And why would you want to do something like that? Why is a different signature
not a problem?
BTW, have you looked at GCC's __builtin_apply_args and __builtin_apply?
https://godbolt.org/z/9f1GMnG74
> A fourth use case is recreational hacking but I don't know if that counts
> standards-wise.
I don't think any of the use-cases count Standards-wise.
Don't get me wrong, I think the feature is useful... as an extension. And
probably with different syntax. It's pretty easy to do this with LD_PRELOAD
already for the 99% case where you do know what the arguments to the functions
are.
I don't think we need a Standards feature that is going to cater for the 1 use
per year on the entire planet.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-05-01 16:22:54
