When using VC6.0 to compile. C file, if you define variables in any place in the program, the above error will occur;
Reason: Generally in ANSI C or C++, it is allowed to define variables at any time in executable code, but in K& It’s not allowed in R and C, and that’s why we have this error. VC6.0, VS2008 are used K& R C to implement the C language, so the compilation process will report errors.
In pure C, variable declarations for a block of code are usually at the front end.
Solution: 1. Put all variable declarations at the beginning.
2. Save the file as. CPP file.
Reason: Generally in ANSI C or C++, it is allowed to define variables at any time in executable code, but in K& It’s not allowed in R and C, and that’s why we have this error. VC6.0, VS2008 are used K& R C to implement the C language, so the compilation process will report errors.
In pure C, variable declarations for a block of code are usually at the front end.
Solution: 1. Put all variable declarations at the beginning.
2. Save the file as. CPP file.
Read More:
- Solutions to error c2143: syntax error: missing ‘;’ before ‘type’ in C + + program compilation
- C error C2143 syntax error missing before ‘type’
- winnt.h C2146 error C2146: syntax error : missing ‘;’ before identifier ‘PVOID64’
- error C2146: syntax error : missing ‘;’ before identifier ‘fd’
- Solve the problem of error: cannot pass objects of non trivially copyable type ‘STD:: String’ in C / C + +
- C++ Error: allocating an object of abstract class type
- Solution to command line option syntax error. Type command /? For help
- Error c2061: syntax error: identifier ‘this_ FILE’
- Front end project runtime prompts syntax error: typeerror: token.type.endswith is not a function solution
- C++ : [Error] ‘ostream’ does not name a type
- Error c2059: syntax error: constant solution
- C language string processing error warning, c4996, sprintf, predicted, c4996, strcpy, c4996, strcat
- Error: missing `server’ JVM at `C:\Program Files (x86)\Java\jre1.8.0_231\bin\server\jvm.dll’.
- C + + common errors: “error: XXX in namespace ‘STD’ does not name a template type”
- [Solved] Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
- When C language refers to a user-defined type as a parameter, an error segmentation fault is reported
- Error c2011: “a certain class”: redefinition of “class” type
- error: non-const lvalue reference to type cannot bind to a value of unrelated type
- error C2061: syntax error : identifier ‘BinryTreeNode’
- Syntax error: invalid syntax before Python string