HELP - double including? redefining functions

05 Mar 2011

Hi guys,

I ran into an issue today when programing my project today. I have a set of functions under ERRORLIGHT.h. Then I have MAIN.ccp and SENSOR.h. (note that i have multiple sensors it just easier to describe like this.)

MAIN.ccp #includes SENSOR.h and #ERRORLIGHT.h

SENSOR.h #include ERRORLIGHT.h

/* Errorlight is a set of functions that will display led blinks depending on what sensor or specific action triggers it.

  • /

ERROR: errorLightOn() multipled defined in SENSOR.h to MAIN.cpp EL6200E

Is there a way to get by this issue?

05 Mar 2011

When you create a header file you should always wrap it thus to prevent this:-

in SENSOR.h:-

SENSOR.h

#ifndef SENSOR_H
#define SENSOR_H

// .. you stuff

#endif

In ERRORLIGHT.h

ERRORLIGHT.h

#ifndef ERRORLIGHT_H
#define ERRORLIGHT_H

// ... you stuff

#endif

06 Mar 2011

Thank You worked perfectly