title: Typedef struct declared as two types: "typedef struct x { .. } X, *XPointer"
body: <p>Sorry if this has been asked before, I wasn't really even sure what to search for to come up with this.</p>
  
  <p>When I create a <code>typedef struct</code>, I usually do something like this:</p>
  
  <pre><code>typedef struct myStruct {
    int a;
    int b;
    struct myStruct *next;
  } MyStruct;
  </code></pre>
  
  <p>So I declare it with <code>MyStruct</code> at the end.  Then when I create functions that pass that in as a parameter, I write</p>
  
  <pre><code>int doSomething(MyStruct *ptr){
  
  }
  </code></pre>
  
  <p>Yet I am collaborating with a friend on a project and I have come across his coding style, which is to <em>also</em> declare <code>*MyStructP</code> like this:</p>
  
  <pre><code>typedef struct myStruct {
    int a;
    int b;
    struct myStruct *next;
  } MyStructR, *MyStructP;
  </code></pre>
  
  <p>And then he uses <code>MyStructP</code> in his functions, so his parameters look like:</p>
  
  <pre><code>int doSomething(MyStructP)
  </code></pre>
  
  <p>So he doesn't have to use the <code>*</code> in the parameter list.  This confused me because when I look at the parameter list, I always look for the <code>*</code> to determine if the arg is a pointer or not.  On top of that, I am creating a function that takes in a struct I created and a struct he created, so my arg has the * and his does not. Ultra confusing!!</p>
  
  <p>Can someone give insight/comparison/advice on the differences between the two? Pros? Cons? Which way is better or worse, or more widely used? Any information at all. Thanks!</p>