adafruit dht library, pi_2_mmio will not compile

I'm working with the c code in the dht library to control a DHT 11 with a raspberry pi using c++. However my code will not compile, it throws these errors:

pi_2_mmio.c:36:20: error: redefinition of 'volatile uint32_t* pi_2_mmio_gpio'
pi_2_mmio.h:34:20: error 'volatile uint32_t* pi_w_mmio_gpio' previously declared here

I looked at both files, pi_2_mmio.h declares the variable (pointer?) 'volatile uint32_t* pi_w_mmio_gpio' and pi_2_mmio.c assigns the value NULL to it......
why is the compiler reading the assignment statement as a second definition?
I'm using g++
please help!

you can get the files i mentioned here: https://github.com/adafruit/Adafruit_Python_DHT/tree/master/source/Raspberry_Pi_2
why is the compiler reading the assignment statement as a second definition?
 
volatile uint32_t* pi_2_mmio_gpio = NULL;

It's not an "assignment statement". It is a definition (and initialization) of pi_2_mmio_gpio.

To make it work you should change the definition of pi_2_mmio_gpio in the header file to a declaration by using the extern keyword .
 
extern volatile uint32_t* pi_2_mmio_gpio;
Topic archived. No new replies allowed.