q: code that generates printf() statement to dump C struct contents
- From: joachim.gann@xxxxxxxxx
- Date: Tue, 29 Apr 2008 09:42:42 -0700 (PDT)
Hi,
I am sure, others also have had a need for this.
I am examining a C API for the first time, writing small test programs
and dumping the contents of C structs.
What I am looking for is a code fragment or tool that will take a C
struct declaration as input, maybe even complete header files with
typedefs and the like and generates a dump_struct function that takes
a pointer to the actual struct as input and then dumps or displays the
structs' contents via printf(), leaving the comments from the header
file intact.
any hints?
Joachim
generated code would be something like:
void dump_struct_xx( struct xx *p )
{
printf("struct xx {\n\\
int xy=%d; /* comment from the header file */\n\\
}", p->xy );
}
.
- Follow-Ups:
- Re: q: code that generates printf() statement to dump C struct contents
- From: Jens Thoms Toerring
- Re: q: code that generates printf() statement to dump C struct contents
- From: Ian Collins
- Re: q: code that generates printf() statement to dump C struct contents
- Prev by Date: Re: sharing memory map between processes (same parent)
- Next by Date: Re: TCP connect in Non Blocking Mode
- Previous by thread: switch(??)
- Next by thread: Re: q: code that generates printf() statement to dump C struct contents
- Index(es):
Relevant Pages
|
|