Meaning of son of a gun

son' of a gun'

Pronunciation: [key]
— pl. sons of guns.
  1. rogue; rascal; scoundrel: That son of a gun still owes me $20.
  2. a tiresome or disagreeable matter, chore, etc.
  3. (used as an affectionate greeting, term of address, etc.): Charlie Humpelmeyer, you old son of a gun, how are you?
  4. (used as an exclamation of irritation, surprise, dismay, etc.).
Random House Unabridged Dictionary, Copyright © 1997, by Random House, Inc., on Infoplease.