Derivation on p.99 of Salanie, The Economics of Taxation (2nd edition) Starting on p. 98 of Salanie's "The Economic of Taxation" (2nd edition), it explains


  To probe it more rigorously, let us define the utility of taxpayer $w$ when he claims to have productivity $w'$:
  $$
V(w', w) = u(C(w'), Y(w'), w).
$$
  For the mechanism to be revealing, $V$ must be maximal in $w' = w$. Assume that all functions are differentiable and that income $Y$ is positive. Then we have the first-order necessary condition
  $$
\frac{\partial V}{\partial w'} (w, w) = 0 \tag{NC1}
$$
  and the second-order necessary condition
  $$
\frac{\partial^2 V}{\partial w'^2}(w,w) \leq 0 \tag{NC2}.
$$
  Differentiating (NC1) gives us
  $$
\frac{\partial^2 V}{\partial w'^2} + \frac{\partial^2 V}{\partial w' \partial w} = 0
$$
  ...


My question is this: How do we arrive at the last equation from (NC1)? If I differentiate 
$$
\frac{\partial V}{\partial w'} (w', w)
$$
with respect to $w$, don't I just end up with $\frac{\partial^2 V}{\partial w'\partial w}$? Likewise, if I differentiate with respect to $w'$, I end up with
$\frac{\partial^2 V}{\partial w'^2}$. What am I missing?
Why are you doing $\frac{\partial^2 V}{\partial w'^2}$ ? 

Even if it is said that $w^{'}=w$ at the optimum, it should be taken different when you differentiate it for first order conditions. So, you differentiate it according to $w^{'}$ and $w$.