Hoping that someone could provide some insight into the below 'error' that VS code is flagging in my C++ code.
I recently got a new laptop (Macbook Pro M1 Pro chip) so I have set up my environment now. Everything looks good, however I seem to be getting reference initialisation and expected expression errors in a for loop that I wasnt previously getting - My other computer (Mac Mini M1 chip) does not have this issue and doesnt flag any errors.
To note: The full code compiles fine, so there shouldn't be any issue with it, but interested to hear peoples thoughts and potentially a way to get rid of the error appearing?
Example code block (I have a few for loops that are similar but serve different purposes, they are all showing the same error):
Wallet &Blockchain::GetChainWallet(string WalletAddress)
{
for (Wallet &ChainWallet : _vWallets)
{
if (WalletAddress == ChainWallet.GetWalletID())
{
return ChainWallet;
break;
}
}
}
The errors I'm receiving are:
reference variable "ChainWallet" requires an initializer
expected an expression
Full:
[{
"resource": "/Users/carlbrand/Documents/GitHub/BRIK/src/cpp/Blockchain/Blockchain.cpp",
"owner": "C/C++",
"code": "252",
"severity": 8,
"message": "reference variable \"ChainWallet\" requires an initializer",
"source": "C/C++",
"startLineNumber": 70,
"startColumn": 30,
"endLineNumber": 70,
"endColumn": 31
}]
[{
"resource": "/Users/carlbrand/Documents/GitHub/BRIK/src/cpp/Blockchain/Blockchain.cpp",
"owner": "C/C++",
"code": "29",
"severity": 8,
"message": "expected an expression",
"source": "C/C++",
"startLineNumber": 70,
"startColumn": 41,
"endLineNumber": 70,
"endColumn": 42
}]
Is there anything wrong with what I'm doing? I just want to get rid of the errors :)
Thanks in advance.