Scope ?Scope and Global variables

Ok, so I have a structure variable "EPD" declared before setup, so that should make it a global variable should it not ?

// Create the EEPROM data structure
struct udt_EPD {
unsigned long eeprom_writes;
uint16_t      cal_min;
uint16_t      cal_max;
uint8_t       minutes_run;
unsigned long hours_run;
uint8_t       id;               // this is last to catch structure changes
};

//Create the EEPROM data of type udt_EPD
udt_EPD EPD;

// **********************************************************************

void setup() 
{

This from the help - " any variable declared outside of a function (e.g. setup(), loop(), etc. ), is a global variable."

now I've written a function to update the contents of the EEPROM, and it automatically increments the number of writes member before writing the EEPROM data, this function follows the end of void loop() ...

void update_EPD()
(
  EPD.eeprom_writes++;
  EEPROM.put(EPA, EPD);
}

I'm confused why I'm getting "update_EPD" was not declared in this scope" errors whenever I call the function.

pRojeCt_Compressor_Nano:168:5: error: 'update_EPD' was not declared in this scope
update_EPD();
^~~~~~~~~~

Similar topics have not been helpful.... so far ...

Any help would be appreciated...

Mind your braces… { }.

a7

BOOM ! thanks ....

This error has nothing to do with scope of EPD variable, the problem is that your function update_EPD() is not declared.

Well it is, but I put a parenthesis opening brace instead of a curly one ....

Eyesight not so good as it used to be, oh how I wish we could use square braces as an alternative, but I guess that would men major changes to all of the compilers !!!

You can get help with all that from a good text editor. Even the IDE text editor makes it easy to find missing or mismatched braces.

Using the Autoformat tool in the IDE will turn up lotsa mistakes.

But yeah, we must live with braces, brackets and parentheses and what they have meant for decades.

You could switch to a modern language. :wink:

And ditch the Arduino stuff.

a7

Such as ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.