V: Centos 7.5 compile v.c failed

Created on 23 Jun 2019  Â·  11Comments  Â·  Source: vlang/v

[root@centos75 compiler]# gcc -w -o vc v.c -std=c99
v.c:341:3: error: expected specifier-qualifier-list before ‘_Atomic’
   _Atomic int fn_cnt;
   ^
v.c: In function ‘Fn_str’:
v.c:13789:21: error: unknown field ‘fn_cnt’ specified in initializer
                     .fn_cnt = 0,
                     ^
v.c:13790:21: error: unknown field ‘obfuscate’ specified in initializer
                     .obfuscate = 0};
                     ^
v.c: In function ‘new_table’:
v.c:13808:3: error: unknown field ‘obfuscate’ specified in initializer
   Table *t = ALLOC_INIT(Table, {
   ^
v.c:13808:3: error: unknown field ‘fn_cnt’ specified in initializer
v.c: In function ‘Table_cgen_name’:
v.c:14653:12: error: ‘Table’ has no member named ‘obfuscate’
   if (table->obfuscate && string_ne(f->name, tos2("main")) &&
            ^
v.c:14673:12: error: ‘Table’ has no member named ‘fn_cnt’
       table->fn_cnt++;
            ^
v.c:14674:24: error: ‘Table’ has no member named ‘fn_cnt’
       int tmp68 = table->fn_cnt;
                        ^
v.c:14678:18: error: ‘Table’ has no member named ‘fn_cnt’
       idx = table->fn_cnt;
                  ^
[root@centos75 compiler]#

gcc version

[root@centos75 compiler]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
[root@centos75 compiler]#

OS version:

[root@centos75 compiler]# uname -a
Linux centos75 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@centos75 compiler]#

Related issue: centos6 centos7 can not compile v with vc #356

Bug Needs More Info

Most helpful comment

Solved the problem by upgrading gcc, the command list:

yum install centos-release-scl
yum install devtoolset-8
scl enable devtoolset-8 bash

gcc version:

[root@centos75 examples]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.2.1-20180905/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)

build log:

[root@centos75 compiler]# make
wget https://vlang.io/v.c
--2019-06-24 11:19:53--  https://vlang.io/v.c
Resolving vlang.io (vlang.io)... 3.91.188.13
Connecting to vlang.io (vlang.io)|3.91.188.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 321193 (314K) [application/octet-stream]
Saving to: ‘v.c’

100%[=============================================================================================================================================================================================>] 321,193      152KB/s   in 2.1s

2019-06-24 11:19:57 (152 KB/s) - ‘v.c’ saved [321193/321193]

cc -std=gnu11 -w -o vc v.c
./vc -o v .
[root@centos75 compiler]#

This method only affects the current terminal session, and it feels that the code compilation of v will depend on the current C language build environment..

All 11 comments

@medvednikov

#353
clang works for me

yum install clang
clang -w -o vc v.c

image

thanks.

#353
clang works for me

yum install clang
clang -w -o vc v.c

image

There're other burning problem as below:
./vc -o v .
cc: error: unrecognized command line option ‘-mmacosx-version-min=10.7’
V panic: clang error

Solved it: #507

can you try #486 ?

@whoizit try #486 build log:

[root@centos75 compiler]# make
wget https://vlang.io/v.c
--2019-06-24 10:33:08--  https://vlang.io/v.c
Resolving vlang.io (vlang.io)... 3.91.188.13
Connecting to vlang.io (vlang.io)|3.91.188.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 321193 (314K) [application/octet-stream]
Saving to: ‘v.c’

100%[======================================>] 321,193      150KB/s   in 2.1s

2019-06-24 10:33:13 (150 KB/s) - ‘v.c’ saved [321193/321193]

cc -std=gnu11 -w -o vc v.c
v.c:355:3: error: expected specifier-qualifier-list before ‘_Atomic’
   _Atomic int fn_cnt;
   ^
v.c: In function ‘Fn_str’:
v.c:13776:21: error: unknown field ‘fn_cnt’ specified in initializer
                     .fn_cnt = 0,
                     ^
v.c:13777:21: error: unknown field ‘obfuscate’ specified in initializer
                     .obfuscate = 0};
                     ^
v.c: In function ‘new_table’:
v.c:13795:3: error: unknown field ‘obfuscate’ specified in initializer
   Table *t = ALLOC_INIT(Table, {
   ^
v.c:13795:3: error: unknown field ‘fn_cnt’ specified in initializer
v.c: In function ‘Table_cgen_name’:
v.c:14640:12: error: ‘Table’ has no member named ‘obfuscate’
   if (table->obfuscate && string_ne(f->name, tos2("main")) &&
            ^
v.c:14660:12: error: ‘Table’ has no member named ‘fn_cnt’
       table->fn_cnt++;
            ^
v.c:14661:24: error: ‘Table’ has no member named ‘fn_cnt’
       int tmp68 = table->fn_cnt;
                        ^
v.c:14665:18: error: ‘Table’ has no member named ‘fn_cnt’
       idx = table->fn_cnt;
                  ^
make: *** [vc] Error 1
[root@centos75 compiler]#

centos 7.5 (1810) default gcc version:

[root@centos75 compiler]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

_Atomic defined in stdatomic.h

find stdatomic.h in centos 7.5

[root@centos75 compiler]# find / -name stdatomic.h
[root@centos75 compiler]#  <<<empty>>

See Bug 58016 - stdatomic.h missing in 4.8.1

It seems that only the default gcc can be upgraded on centos7.5 to solve this build issue.

Try building with clang.

[root@centos75 compiler]# clang -v
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5
[root@centos75 compiler]#

build log:

[root@centos75 compiler]# clang -std=gnu11 -w -o vc v.c or clang -std=c11 -w -o vc v.c
[root@centos75 compiler]# ./vc -o v .
/root//.vlang//v.c:355:1: error: expected specifier-qualifier-list before ‘_Atomic’
 _Atomic
 ^
/root//.vlang//v.c: In function ‘array_repeat’:
/root//.vlang//v.c:1064:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:1064:2: note: use option -std=c99 or -std=gnu99 to compile your code
/root//.vlang//v.c: In function ‘array_append_array’:
/root//.vlang//v.c:1079:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘array_int_str’:
/root//.vlang//v.c:1326:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘array_string_str’:
/root//.vlang//v.c:1361:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_clone’:
/root//.vlang//v.c:1462:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_replace’:
/root//.vlang//v.c:1512:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:1559:5: error: redefinition of ‘i’
 int i= 0  ;  i < s .len  ;  i ++ ) {
     ^
/root//.vlang//v.c:1513:5: note: previous definition of ‘i’ was here
 int i= 0  ;  i < s .len  ;  i ++ ) {
     ^
/root//.vlang//v.c:1558:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:1564:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_eq’:
/root//.vlang//v.c:1640:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_lt’:
/root//.vlang//v.c:1669:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_add’:
/root//.vlang//v.c:1732:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:1741:5: error: redefinition of ‘j’
 int j= 0  ;  j < a .len  ;  j ++ ) {
     ^
/root//.vlang//v.c:1733:5: note: previous definition of ‘j’ was here
 int j= 0  ;  j < s .len  ;  j ++ ) {
     ^
/root//.vlang//v.c:1740:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_split_into_lines’:
/root//.vlang//v.c:1920:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_to_lower’:
/root//.vlang//v.c:2201:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_to_upper’:
/root//.vlang//v.c:2218:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘array_string_contains’:
/root//.vlang//v.c:2266:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp75 = 0; tmp75 < tmp74 .len; tmp75 ++) {
 ^
/root//.vlang//v.c: In function ‘array_int_contains’:
/root//.vlang//v.c:2290:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp76 .len; i ++) {
 ^
/root//.vlang//v.c: In function ‘array_string_to_c’:
/root//.vlang//v.c:2314:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_ustring’:
/root//.vlang//v.c:2547:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_ustring_tmp’:
/root//.vlang//v.c:2579:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘v_array_string_free’:
/root//.vlang//v.c:2708:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp105 = 0; tmp105 < tmp104 .len; tmp105 ++) {
 ^
/root//.vlang//v.c: In function ‘array_string_join’:
/root//.vlang//v.c:2789:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp110 .len; i ++) {
 ^
/root//.vlang//v.c:2809:10: error: redefinition of ‘i’
 for (int i = 0; i < tmp113 .len; i ++) {
          ^
/root//.vlang//v.c:2789:10: note: previous definition of ‘i’ was here
 for (int i = 0; i < tmp110 .len; i ++) {
          ^
/root//.vlang//v.c:2809:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp113 .len; i ++) {
 ^
/root//.vlang//v.c:2812:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:2827:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘repeat_char’:
/root//.vlang//v.c:2897:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘string_hash’:
/root//.vlang//v.c:2916:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘range_int’:
/root//.vlang//v.c:3122:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘array_byte_contains’:
/root//.vlang//v.c:3414:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp29 = 0; tmp29 < tmp28 .len; tmp29 ++) {
 ^
/root//.vlang//v.c: In function ‘string_utf32_code’:
/root//.vlang//v.c:3983:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘map__set’:
/root//.vlang//v.c:4026:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘map_keys’:
/root//.vlang//v.c:4165:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘map_get’:
/root//.vlang//v.c:4193:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘v_map_print’:
/root//.vlang//v.c:4221:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘map_string_str’:
/root//.vlang//v.c:4250:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp33 = 0; tmp33 < tmp32 .len; tmp33 ++) {
 ^
/root//.vlang//v.c: In function ‘smap_get’:
/root//.vlang//v.c:4297:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘smap_str’:
/root//.vlang//v.c:4422:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp20 = 0; tmp20 < tmp19 .len; tmp20 ++) {
 ^
/root//.vlang//v.c: In function ‘os__init_os_args’:
/root//.vlang//v.c:4481:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘os__read_file_into_ulines’:
/root//.vlang//v.c:4650:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp18 = 0; tmp18 < tmp17 .len; tmp18 ++) {
 ^
/root//.vlang//v.c: In function ‘CGen_register_thread_fn’:
/root//.vlang//v.c:5931:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp12 = 0; tmp12 < tmp11 .len; tmp12 ++) {
 ^
/root//.vlang//v.c: In function ‘V_prof_counters’:
/root//.vlang//v.c:5958:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp17 = 0; tmp17 < tmp16 .len; tmp17 ++) {
 ^
/root//.vlang//v.c:5968:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp20 = 0; tmp20 < tmp19 .len; tmp20 ++) {
 ^
/root//.vlang//v.c:5973:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp22 = 0; tmp22 < tmp21 .len; tmp22 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_print_prof_counters’:
/root//.vlang//v.c:5995:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp26 = 0; tmp26 < tmp25 .len; tmp26 ++) {
 ^
/root//.vlang//v.c:6007:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp30 = 0; tmp30 < tmp29 .len; tmp30 ++) {
 ^
/root//.vlang//v.c:6012:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp32 = 0; tmp32 < tmp31 .len; tmp32 ++) {
 ^
/root//.vlang//v.c: In function ‘Fn_find_var’:
/root//.vlang//v.c:6087:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp2 = tmp1; tmp2 <  f ->var_idx; tmp2++) {
 ^
/root//.vlang//v.c: In function ‘Fn_mark_var_used’:
/root//.vlang//v.c:6144:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp11 .len; i ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_fn_decl’:
/root//.vlang//v.c:6744:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp51 = 0; tmp51 < tmp50 .len; tmp51 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_async_fn_call’:
/root//.vlang//v.c:6815:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp58 .len; i ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_fn_args’:
/root//.vlang//v.c:7076:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp80 = 0; tmp80 < tmp79 .len; tmp80 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_fn_call_args’:
/root//.vlang//v.c:7163:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp84 .len; i ++) {
 ^
/root//.vlang//v.c:7338:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp95 = 0; tmp95 < tmp94 .len; tmp95 ++) {
 ^
/root//.vlang//v.c: In function ‘contains_capital’:
/root//.vlang//v.c:7433:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘Fn_typ_str’:
/root//.vlang//v.c:7463:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp105 .len; i ++) {
 ^
/root//.vlang//v.c: In function ‘Fn_str_args’:
/root//.vlang//v.c:7500:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp107 .len; i ++) {
 ^
/root//.vlang//v.c:7512:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp110 = 0; tmp110 < tmp109 .len; tmp110 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_gen_json_for_type’:
/root//.vlang//v.c:7618:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp11 = 0; tmp11 < tmp10 .len; tmp11 ++) {
 ^
/root//.vlang//v.c: In function ‘V_compile’:
/root//.vlang//v.c:7865:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp6 = 0; tmp6 < tmp5 .len; tmp6 ++) {
 ^
/root//.vlang//v.c:7953:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp11 = 0; tmp11 < tmp10 .len; tmp11 ++) {
 ^
/root//.vlang//v.c:8043:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp16 = 0; tmp16 < tmp15 .len; tmp16 ++) {
 ^
/root//.vlang//v.c:8072:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp18 = 0; tmp18 < tmp17 .len; tmp18 ++) {
 ^
/root//.vlang//v.c: In function ‘V_cc’:
/root//.vlang//v.c:8186:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp30 = 0; tmp30 < tmp29 .len; tmp30 ++) {
 ^
/root//.vlang//v.c: In function ‘V_v_files_from_dir’:
/root//.vlang//v.c:8350:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp50 = 0; tmp50 < tmp49 .len; tmp50 ++) {
 ^
/root//.vlang//v.c: In function ‘V_add_user_v_files’:
/root//.vlang//v.c:8466:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp61 = 0; tmp61 < tmp60 .len; tmp61 ++) {
 ^
/root//.vlang//v.c:8499:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp64 = 0; tmp64 < tmp63 .len; tmp64 ++) {
 ^
/root//.vlang//v.c:8512:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:8521:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp72 = 0; tmp72 < tmp71 .len; tmp72 ++) {
 ^
/root//.vlang//v.c:8538:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c:8547:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp80 = 0; tmp80 < tmp79 .len; tmp80 ++) {
 ^
/root//.vlang//v.c:8575:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp83 = 0; tmp83 < tmp82 .len; tmp83 ++) {
 ^
/root//.vlang//v.c:8592:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp87 = 0; tmp87 < tmp86 .len; tmp87 ++) {
 ^
/root//.vlang//v.c:8605:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp90 = 0; tmp90 < tmp89 .len; tmp90 ++) {
 ^
/root//.vlang//v.c: In function ‘new_v’:
/root//.vlang//v.c:8823:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp111 = 0; tmp111 < tmp110 .len; tmp111 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_parse’:
/root//.vlang//v.c:9187:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘Parser_dot’:
/root//.vlang//v.c:11540:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp142 = 0; tmp142 < tmp141 .len; tmp142 ++) {
 ^
/root//.vlang//v.c:11552:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp144 = 0; tmp144 < tmp143 .len; tmp144 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_assoc’:
/root//.vlang//v.c:12688:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp201 = 0; tmp201 < tmp200 .len; tmp201 ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_struct_init’:
/root//.vlang//v.c:13420:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp240 .len; i ++) {
 ^
/root//.vlang//v.c:13479:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp244 .len; i ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_js_decode’:
/root//.vlang//v.c:14735:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp308 = 0; tmp308 < tmp307 .len; tmp308 ++) {
 ^
/root//.vlang//v.c: In function ‘is_compile_time_const’:
/root//.vlang//v.c:14829:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp316 = 0; tmp316 < tmp315 .len; tmp316 ++) {
 ^
/root//.vlang//v.c: In function ‘Type_str’:
/root//.vlang//v.c:16180:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp3 = 0; tmp3 < tmp2 .len; tmp3 ++) {
 ^
/root//.vlang//v.c:16198:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp5 = 0; tmp5 < tmp4 .len; tmp5 ++) {
 ^
/root//.vlang//v.c: In function ‘Fn_str’:
/root//.vlang//v.c:16220:1: error: unknown field ‘fn_cnt’ specified in initializer
 Table t= (Table){ .types = new_array(0, 1, sizeof(Type)) , .consts = new_array(0, 1, sizeof(Var)) , .fns = new_array(0, 1, sizeof(Fn)) , .packages = new_array(0, 1, sizeof(string)) , .imports = new_array(0, 1, sizeof(string)) , .flags = new_array(0, 1, sizeof(string)) , .fn_cnt = 0 , .obfuscate = 0 } ;
 ^
/root//.vlang//v.c:16220:1: error: unknown field ‘obfuscate’ specified in initializer
/root//.vlang//v.c: In function ‘new_table’:
/root//.vlang//v.c:16245:1: error: unknown field ‘obfuscate’ specified in initializer
 Table* t= ALLOC_INIT(Table, { .obf_ids =  new_map(1, sizeof(int)) , .obfuscate =  obfuscate , .types = new_array(0, 1, sizeof(Type)) , .consts = new_array(0, 1, sizeof(Var)) , .fns = new_array(0, 1, sizeof(Fn)) , .packages = new_array(0, 1, sizeof(string)) , .imports = new_array(0, 1, sizeof(string)) , .flags = new_array(0, 1, sizeof(string)) , .fn_cnt = 0 , } ) ;
 ^
/root//.vlang//v.c:16245:1: error: unknown field ‘fn_cnt’ specified in initializer
/root//.vlang//v.c: In function ‘Table_register_fn’:
/root//.vlang//v.c:16364:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp13 = 0; tmp13 < tmp12 .len; tmp13 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_known_type’:
/root//.vlang//v.c:16395:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp16 = 0; tmp16 < tmp15 .len; tmp16 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_find_fn’:
/root//.vlang//v.c:16419:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp18 = 0; tmp18 < tmp17 .len; tmp18 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_known_fn’:
/root//.vlang//v.c:16443:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp20 = 0; tmp20 < tmp19 .len; tmp20 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_register_type’:
/root//.vlang//v.c:16485:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp23 = 0; tmp23 < tmp22 .len; tmp23 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_register_type_with_parent’:
/root//.vlang//v.c:16527:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp28 = 0; tmp28 < tmp27 .len; tmp28 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_register_type2’:
/root//.vlang//v.c:16561:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp32 = 0; tmp32 < tmp31 .len; tmp32 ++) {
 ^
/root//.vlang//v.c: In function ‘Type_find_field’:
/root//.vlang//v.c:16601:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp38 = 0; tmp38 < tmp37 .len; tmp38 ++) {
 ^
/root//.vlang//v.c: In function ‘Type_find_method’:
/root//.vlang//v.c:16698:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp48 = 0; tmp48 < tmp47 .len; tmp48 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_find_type’:
/root//.vlang//v.c:16763:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int i = 0; i < tmp51 .len; i ++) {
 ^
/root//.vlang//v.c: In function ‘Parser_satisfies_interface’:
/root//.vlang//v.c:17022:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp57 = 0; tmp57 < tmp56 .len; tmp57 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_is_interface’:
/root//.vlang//v.c:17116:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp59 = 0; tmp59 < tmp58 .len; tmp59 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_main_exists’:
/root//.vlang//v.c:17140:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp61 = 0; tmp61 < tmp60 .len; tmp61 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_find_const’:
/root//.vlang//v.c:17164:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp63 = 0; tmp63 < tmp62 .len; tmp63 ++) {
 ^
/root//.vlang//v.c: In function ‘Table_cgen_name’:
/root//.vlang//v.c:17213:13: error: ‘Table’ has no member named ‘obfuscate’
  if ( table ->obfuscate  && string_ne( f ->name , tos2("main") )  && string_ne( f ->name , tos2("WinMain") )  && string_ne( f ->pkg , tos2("builtin") )  &&  ! f ->is_c  && string_ne( f ->pkg , tos2("darwin") )  && string_ne( f ->pkg , tos2("os") )  &&  ! string_contains( f ->name , tos2("window_proc") )  && string_ne( f ->name , tos2("gg__vec2") )  && string_ne( f ->name , tos2("build_token_str") )  && string_ne( f ->name , tos2("build_keys") )  && string_ne( f ->pkg , tos2("json") )  &&  ! string_ends_with( name , tos2("_str") )  &&  ! string_contains( name , tos2("contains") ) ) {
             ^
/root//.vlang//v.c:17222:8: error: ‘Table’ has no member named ‘fn_cnt’
  table ->fn_cnt ++ ;
        ^
/root//.vlang//v.c:17223:20: error: ‘Table’ has no member named ‘fn_cnt’
 int tmp68 =  table ->fn_cnt;
                    ^
/root//.vlang//v.c:17227:16: error: ‘Table’ has no member named ‘fn_cnt’
  idx  =  table ->fn_cnt ;
                ^
/root//.vlang//v.c: In function ‘build_keys’:
/root//.vlang//v.c:17298:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (
  ^
/root//.vlang//v.c: In function ‘array_Token_contains’:
/root//.vlang//v.c:17651:1: error: ‘for’ loop initial declarations are only allowed in C99 mode
 for (int tmp110 = 0; tmp110 < tmp109 .len; tmp110 ++) {
 ^
V panic: clang error
[root@centos75 compiler]#

working directory:

[root@centos75 compiler]# pwd
/root/code/v/compiler
[root@centos75 compiler]#

Solved the problem by upgrading gcc, the command list:

yum install centos-release-scl
yum install devtoolset-8
scl enable devtoolset-8 bash

gcc version:

[root@centos75 examples]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.2.1-20180905/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)

build log:

[root@centos75 compiler]# make
wget https://vlang.io/v.c
--2019-06-24 11:19:53--  https://vlang.io/v.c
Resolving vlang.io (vlang.io)... 3.91.188.13
Connecting to vlang.io (vlang.io)|3.91.188.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 321193 (314K) [application/octet-stream]
Saving to: ‘v.c’

100%[=============================================================================================================================================================================================>] 321,193      152KB/s   in 2.1s

2019-06-24 11:19:57 (152 KB/s) - ‘v.c’ saved [321193/321193]

cc -std=gnu11 -w -o vc v.c
./vc -o v .
[root@centos75 compiler]#

This method only affects the current terminal session, and it feels that the code compilation of v will depend on the current C language build environment..

The compilation bug is believed to be fixed in 0.1.0. Could you please check?

GCC7.x or the other higher version can compile V.

@zhengshuxin @lutherwenxu

  • Download v_linux.zip, build code/v/examples/hello_world.v failed.

  • git pull latest version && cd code/v/compiler && make Still fail

This is caused by the behavior of calling the default gcc, this problem is no longer tried, I plan to use redhat8.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vtereshkov picture vtereshkov  Â·  3Comments

taojy123 picture taojy123  Â·  3Comments

XVilka picture XVilka  Â·  3Comments

oleg-kachan picture oleg-kachan  Â·  3Comments

radare picture radare  Â·  3Comments