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] Keepalived Configurate Error: Unicast peers are not supported in strict mode
- [Solved] Linux — 9 — txt files are copied from windows to Linux and read error
- [Solved] Linux C++ warning: ISO C++ forbids converting a string constant to ‘char*‘ [-Wwrite-strings]
- Chinese garbled problem when running. C file in Linux
- Prompt “entering emergency mode. Exit the shell to continue” if the Linux operating system does not start normally
- [Solved] Linux gcc Compile Error: unknown type name ‘bool‘
- Linux yum Error: All mirror URLs are not using ftp
- [Solved] Nginx Startup Error: directive is not allowed here in
- [Solved] Linux Kernel Compile Error: make menuconfig‘ requires the ncurses libraries
- C++ Compile Error: ld returned 1 exit status [How to Solve]
- The solution to the crash loop back off error of coredns in k8s deployment
- Parse error in ubantu/Linux system [How to Solve]
- Ubuntu18.04 Compile A40i SDK Error: misc/create_inode.c:395:18: error: conflicting types for ‘copy_file_range‘
- [Solved] Error (suppressible): (vsim-12110) All optimizations are disabled because the -novopt option is in effect…
- [Solved] Error in installing backups.lzma for Python on Linux
- Sublime text 3 compiles and executes C/C++ programs directly
- Debian9 g++ Compile Error: error: ‘EDOM’ was not declared in this scope
- CentOS/RHEL 7: How to Reinstall GRUB2 from Rescue Mode (EFI)
- Vector series in actual C + +_ To_ fit()
- Installation and configuration of redis in Linux