Loading a "long" value into eeprom?

#include <EEPROM.h>
long f1; //f1 will equal 7123456
byte buf[4];

buf[0] = byte (f1);
buf[1] = byte f1 >> 8;
buf[2] = byte f1 >> 16;
buf[3] = byte f1 >> 24;

This give the following errors,

long_to_4_bytes:7: error: expected constructor, destructor, or type conversion before ‘=’ token
long_to_4_bytes:8: error: expected constructor, destructor, or type conversion before ‘=’ token
long_to_4_bytes:9: error: expected constructor, destructor, or type conversion before ‘=’ token
long_to_4_bytes:10: error: expected constructor, destructor, or type conversion before ‘=’ token

Any suggestions?

Any suggestions?

Executable code must be in a function. The first line's use of byte is unnecessary. The other three uses are wrong.

You could address the issues that PaulS lists and get your current approach working, but I suggest you look at EEPROMWriteAnything for a much easier approach.

buf[0] = byte (f1);
buf[1] = byte f1 >> 8;
buf[2] = byte f1 >> 16;
buf[3] = byte f1 >> 24;

What computer language do you suppose this is ?