1. Problem description
During the development of embedded Linux, compile and report the following errors
src/util/Vector.c:94:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int j = V->length++; j > i; j--)
^
src/util/Vector.c:94:9: note: use option -std=c99 or -std=gnu99 to compile your code
src/util/Vector.c: In function ‘Vector_remove’:
src/util/Vector.c:123:9: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int j = i; j < V->length; j++)
^
2. Problem analysis
GCC compilation is based on compilation lower than C99 standard. Defining variables within a for loop is not allowed in standards lower than C99.
3. Solution
Method 1
Modify code
int j;
for (j = i; j < V->length; j++)
Method 2
GCC specifies compiling using the C99 standard
gcc -std=c99
Method 3
Specify the C99 standard for compilation in makefile
CFLAGS += -std=c99
Read More:
- [Solved] ubuntu makefile Cross-compilation error: file not recognized: file format not recognized
- C Language Compilation Error: variably modified ‘* *’ at file scope
- Parse error in ubantu/Linux system [How to Solve]
- Sublime text 3 compiles and executes C/C++ programs directly
- Kylin arm64 linux configure: error: cannot guess build type; you must specify one
- Vector series in actual C + +_ To_ fit()
- Linux: How to Fix undefined reference to `itoa’
- [Solved] Error in invoking target ‘agent nmhs‘ of makefile
- error: stray ‘\343’ in program [How to Solve]
- [Linux] undefined reference to `itoa’
- [Solved] rs_to_velodyne-master compile Error: POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::PPFRGBSignature
- [Solved] Ubuntu Open jpg Image Error: Error interpreting JPEG image file (Not a JPEG file: starts with 0x89 0x50)
- How to Delete New Memory in Vector
- Using common file upload to upload files in SSH project
- error: ‘integer_sequence’ is not a member of ‘std’ [How to Solve]
- Solved: could not find the task ‘G + + build active file, leetcode algorithm ACM compilation and debugging
- Ubuntu18.04 Compile Error: android 7 FAILED [How to Solve]
- arm-eabi-gcc: command not found [How to Solve]
- [Solved] FATAL CONFIG FILE ERROR: Bad directive or wrong number of arguments