How to protect wood against carpenter ants?
Pressure-treated lumber, or one of the tropical hardwoods which develops its own insecticides, should be proof against both termites and carpenter ants for many years.

Outside of that, catch and fix rot early, since carpenter ants are most likely to move into wood that has already suffered some damage.