1

I have at my disposal a pretty elaborate printing function to help me debug. Unfortunately, it prints directly to a specified file stream, rather than returning a string (it returns some irrelevant value instead). call doesn't seem to have any parameters when I call help call in GDB. Is it really not possible to hide the return result of the call command? Or is there another command I should be entertaining?

llf
  • 610
  • 10
  • 11

1 Answers1

1

We can cast the result of the function to void to discard its value.


MWE

callnoresult.c

#include <stdio.h>
void pretty_printer() {
        fprintf(stderr, "Hello world!\n");
}

int main() {
        return 0;
}

Then, in terminal:

gcc callnoresult.c -o callnoresult
gdb ./callnoresult

<gdb message>

b main
run
call (void) pretty_printer()

<"Hello world!">

See What does casting to void really do? for more info on the cast.

Community
  • 1
  • 1
llf
  • 610
  • 10
  • 11