title: How do I hide some fields of struct in C?
body: <p>I'm trying to implement a struct person, and I need to hide some fields or make them constant.
  <em>A trick for create private fields.</em></p>
  
  <p>Header:</p>
  
  <pre><code>#pragma once
  
  #define NAME_MAX_LEN 20
  
  typedef struct _person {
      float wage;
      int groupid;
  } Person;
  
  const char const *getName (Person *p);
  int getId (Person *p);
  
  /// OTHER FUNCTIONS
  </code></pre>
  
  <p>Source</p>
  
  <pre><code>#include "person.h"
  
  
  struct _person
  {
      int id;
  
      float wage;
      int groupid;
  
      char name[NAME_MAX_LEN];
  };
  
  /// FUNCTIONS
  </code></pre>
  
  <p>GCC says that <code>person.c:7:8: error: redefinition  a 'struct _person' struct _person</code></p>
  
  <p>I can write this in a header, but after it, I can't use fields of a struct.</p>
  
  <pre><code>typedef struct _person Person;
  </code></pre>