Hi guy, I really need your help. I still get this error:
> Linking .pioenvs\esp12e\firmware.elf
> .pioenvs\esp12e\src\main.cpp.o:(.data.DebugX+0x0): multiple definition of `DebugX’
> .pioenvs\esp12e\src\customFunctions.cpp.o:(.data.DebugX+0x0): first defined here
> collect2.exe: error: ld returned 1 exit status
> *** [.pioenvs\esp12e\firmware.elf] Error 1
I use header guards in my file, so I do not understand why is this part of code redeclared. I had to miss some elementary in cpp programming but I still can’t get it to work.
Copy of my project:
https://bitbucket.org/fires/programingtesting/src/master/ESP8266/cpp/RedefinedError/
main.cpp
#include <Arduino.h>
#include “…/include/defines.h”
//#include “…/include/customFunctions.h”
// Time
uint32_t mTimeToSec = 0;
uint32_t mTimeSeconds = 0;
void setup() {
etc. etc. etc.
customFunction.h
#pragma once
#ifndef CUSTOMFUNCTIONS_H
#define CUSTOMFUNCTIONS_H
void connectWiFi();
void initializeOTA();
#endif
defines.h
#pragma once
#ifndef DEFINES_H
#define DEFINES_H
#include <jled.h>
#define BowlingLed 5
#define StatekLed 4
int DebugX = 1;
#endif
Thanks for the help, I read many articles and many issues but I still do not understand why DebugX is redefined if it is in header guard.