Is there any reason why the code below shouldn't work? (Compile as C Code)
code
#include <stdint.h>
int main()
{
int var = 10;
if (var == 0) return 1;
uint8_t data;
return 0;
}
Error messages
Error 3 error C2065: 'data' : undeclared identifier Error 2 error C2146: syntax error : missing ';' before identifier 'data' Error 1 error C2275: 'uint8_t' : illegal use of this type as an expression
Could this be a bug in vs2013?
To fix above, any of this can be done:
- Return statement in bracets will fix this i.e. if (var == 0) { return; }
- Delcare uint8_t data before the if statements
- Use unsigned char instead of uint8_t
- Compile with C++ "Compile as C++ Code" (Project properties-> C/C++ -> Advanced -> Compile As)
Update: vs2015 (vs140) does not seem to have this "bug"