Hi Sheila
The 1st Regiment of Foot was one of the few regiments to keep two battalions throughout the 19th Century. Both battalions were in the West Indies in 1846. However it was the 1st Battalion that was in Gibraltar from November 1839 to February 1846. Btw…they were in Ireland from January 1836 to April 1838.
I cannot find his service record on Findmypast. FindMyPast also have Regimental Births, but again there is nothing indexed as 1st Foot. You need to ask on the Gib and WI sections for advise on finding their children's births.
I fear the best way forward is to research the muster book/paylists in the National Archives – starting with the 1st Bn/1st Foot when Ann was born. They are not online. Remember to check the 1st Bn Depot which should be in the same book. If you find him you could leap back to William's birth to save time. The first and last entries in the muster usual gives additional information. Also check when he had served 7 and 14 years as they received an extra penny in pay. And again, more information is often recorded. On this occasion being called Smith is an advantage as the Paymaster would usually write their place of birth and previous occupation in red ink, to tell them apart.
He is likely to have been discharged after 21 years. Once you have his regimental number you can check Ancestry for any medals he may have earned.
Added...the 1st Bn 1st Foot were in Nova Scotia for the 1851 census.
Ken