Constipation and Bloating are symptoms and not causes. I think bloating appears after constipation. As for gluten.. i don`t think constipation and gluten are related. The intestines usually assimilate the foods we eat and eliminates the waste. If you think food is the problem, it may be useful to have some medical examination (urine, stool and blood tests).
In this way, you can see if you have some bacteria / viruses in your intestines that causes constipation. This can be a major cause for bot constipation and bloating.
Fermenting foods often cause constipation and long episodes of bloating. For example, fruits and carbonated water. Especially when you eat fruits after a meal.