Using barometer in flight mode code

I would like to get the current altitude out of the barometer’s data in the flight mode code.
But when I’m building with ./waf copter there appears the following error: invalid use of non-static data member ‘Copter::barometer’ barometer.init();
compilation terminated due to -Wfatal-errors.

What can I do? Or is there another way to get the altitude?
Thank you very much!