Measure the length of your hinges as they sit when attached to the gate. Then measure the gate clasp from where it attaches on the gate to the place where it clamps around the post.
Add the length of the hinges on the gate to the length of the gate itself. Then add the length of the clasp from the gate to where it will clamp around the post.
Set the gate posts so that the gate hinges reach one post and the clasp on the other side surrounds the other post securely.
Be sure to leave a space between gates if using a double-swing gate.