Tag Archives: Workplace and development

[Solved] Linux Compile Error: error: ‘for’ loop initial declarations are only allowed in C99 mode

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

ADS1.2 Error: cannot obtain license [How to Solve]

The error is as follows

Modify the license content under the licenses file:
modify it to the following content.

#
# Generated on 2021-dec-1 by licwizard
#
PACKAGE ads armlmd 1.200 E32F0DE5161D COMPONENTS="armasm compiler bats armulate axd adwu fromelf armlink codewarrior armsd"
INCREMENT ads armlmd 1.200 permanent uncounted 612C53EF47C7 HOSTID=ANY ISSUER="Full License by armer, only for educational purpose!" ck=0
FEATURE Win32_CWIDE_Unlimited metrowks 4.2 permanent uncounted D8C287BC5B1B HOSTID=ANY