title: How to print to screen a struct and all its content?
body: <p>I would like to find a macro in <code>c</code>/<code>c++</code> which gets struct <code>typedef</code> and a pointer to a struct as inputs and prints all its content like that:</p>
  
  <p>let say I have a struct named <code>struct account</code>.</p>
  
  <pre><code>struct account {
     int account_number;
     char *first_name;
     char *last_name;
     float balance;
  };
  </code></pre>
  
  <p>and  I use it this way:</p>
  
  <pre><code>struct account my_account= {    
      .account_number = 321321,
      .first_name = 0x12345678,
      .last_name = 0,
      .balance = 222 };
  </code></pre>
  
  <p>I want a macro in linux kernel/ c lanaguge that look like that:</p>
  
  <pre><code>PRINT_STRUCT_CONTENT(struct_type, pointer)
  </code></pre>
  
  <p>and printk the following:</p>
  
  <pre><code>my_account= {
  account_number = 321321,
  first_name = 0x12345678,
  last_name = 0,
  balance = 222
  }
  </code></pre>
  
  <p><em>the idea is to have kind of <code>dir</code> python function in the kernel</em></p>
  
  <hr>
  
  <p><a href="https://stackoverflow.com/questions/11059881/write-a-macro-to-stringify-the-contents-of-a-struct">Write a Macro to stringify the contents of a struct</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3572391/your-most-general-c-macro-for-printing-variable-values-in-different-types">Your most general C macro for printing variable values in different types</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7560086/is-there-a-c-preprocessor-macro-to-print-out-a-struct">Is there a C preprocessor macro to print out a struct?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/319328/writing-a-while-loop-in-the-c-preprocessor">Writing a while loop in the C preprocessor</a></p>