Getting the error "Storage location can only be given for array or struct types" in a setup function. The exact line is
uint memory _total = 0;
I'm confused by the error, because I'm not trying to use storage, I'm trying to use memory.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
The term "storage location" is a bit misleading here, it refers to a more general concept about where data is stored, i.e. in storage or in memory. The error occurs because the "storage location" is only relevant for reference types like structs and arrays and uints are always passed by value, so you cannot hold a reference to a uint in memory or storage. If you want to do that, you have to create a struct data type that only contains a uint.
"For almost all types, you cannot specify where they should be stored"
"local variables of value type (i.e. neither array, nor struct nor mapping) are stored in the stack"
So you can not set storage location for uint