int compiler errors

I have the following code that, I think, used to compile. But with the new compiler I get errors. Not sure what is going on.

code:

int readPassword()
{

byte hbyte = 0;
byte lbyte = 0;

lbyte = EEPROM.read(0);
hbyte = EEPROM.read(1);

//Return the recomposed pw by using bitshift.
return ((lbyte << 0) & 0xFF) + ((hbyte << 8) & 0xFFFF);

}

The call to the function in loop is…

int PassWord = readPassword();

I get the following error:

error: invalid conversion from ‘int (*)()’ to ‘int’ [-fpermissive]

What have I done?

What have I done?

You have failed to post ALL of your code or ALL of your error message(s).

Are you sure you copied that line right? The error message would seem to indicate you may have left off the parenthesis after the function name when you called it.

Is the lowbyte at ‘0’ and highbyte at ‘1’ when the eeprom_read_word() and eeprom_write_word() are used ? I’m not sure.
This reads two bytes from position 0 and 1:

#include <avr/eeprom.h>

#define readPassword() eeprom_read_word( (uint16_t *) 0)

This forces that the byte at ‘0’ is the lowbyte and at ‘1’ is the highbyte:

#include <EEPROM.h>

#define readPassword() word( EEPROM.read(1), EEPROM.read(0))

https://www.arduino.cc/en/Reference/WordCast

P.S.: I didn’t check the code, the macro should be used to store the result into an integer.

@rhartl: Please use code tags.

Read this before posting a programming question

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” icon above the posting area. It is the first icon, with the symbol: </>

Delta_G

Thanks. That was precisely the problem.