These initial steps work fine:
mkdir -p ~/code && cd ~/code # ~/code directory has to be used (it's a temporary limitation)
git clone https://github.com/vlang/v
cd v/compiler
wget https://vlang.io/v.c # Download the V compiler's source translated to
But this fails, whether I use cc or gcc --
$ gcc -w -o vc v.c
v.c: In function ‘array_repeat’:
v.c:1060:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < nr_repeats; i++) {
^
v.c:1060:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
v.c: In function ‘array_append_array’:
v.c:1069:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < b.len; i++) {
^
v.c: In function ‘array_int_str’:
v.c:1251:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < a.len; i++) {
^
v.c: In function ‘array_string_str’:
v.c:1273:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < a.len; i++) {
^
v.c: In function ‘string_clone’:
v.c:1338:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < a.len; i++) {
^
v.c: In function ‘string_replace’:
v.c:1371:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c:1408:12: error: redefinition of ‘i’
for (int i = 0; i < s.len; i++) {
^
v.c:1371:12: note: previous definition of ‘i’ was here
for (int i = 0; i < s.len; i++) {
^
v.c:1408:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c:1413:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int j = 0; j < with.len; j++) {
^
v.c: In function ‘string_eq’:
v.c:1459:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘string_ge’:
v.c:1475:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘string_add’:
v.c:1519:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int j = 0; j < s.len; j++) {
^
v.c:1524:12: error: redefinition of ‘j’
for (int j = 0; j < a.len; j++) {
^
v.c:1519:12: note: previous definition of ‘j’ was here
for (int j = 0; j < s.len; j++) {
^
v.c:1524:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int j = 0; j < a.len; j++) {
^
v.c: In function ‘string_split_into_lines’:
v.c:1660:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘string_to_lower’:
v.c:1857:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘string_to_upper’:
v.c:1868:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘array_string_contains’:
v.c:1901:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp76 = 0; tmp76 < tmp75.len; tmp76++) {
^
v.c: In function ‘array_int_contains’:
v.c:1917:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp77.len; i++) {
^
v.c: In function ‘array_string_to_c’:
v.c:1933:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < a.len; i++) {
^
v.c: In function ‘string_ustring’:
v.c:2092:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘string_ustring_tmp’:
v.c:2118:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘v_array_string_free’:
v.c:2193:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp106 = 0; tmp106 < tmp105.len; tmp106++) {
^
v.c: In function ‘array_string_join’:
v.c:2249:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp111.len; i++) {
^
v.c:2267:12: error: redefinition of ‘i’
for (int i = 0; i < tmp114.len; i++) {
^
v.c:2249:12: note: previous definition of ‘i’ was here
for (int i = 0; i < tmp111.len; i++) {
^
v.c:2267:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp114.len; i++) {
^
v.c:2270:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int j = 0; j < val.len; j++) {
^
v.c:2282:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int k = 0; k < del.len; k++) {
^
v.c: In function ‘repeat_char’:
v.c:2327:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < n; i++) {
^
v.c: In function ‘string_hash’:
v.c:2340:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘range_int’:
v.c:2494:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < len; i++) {
^
v.c: In function ‘array_byte_contains’:
v.c:2717:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp29 = 0; tmp29 < tmp28.len; tmp29++) {
^
v.c: In function ‘string_utf32_code’:
v.c:3237:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 1; i < _rune.len; i++) {
^
v.c: In function ‘map__set’:
v.c:3270:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < m->entries.len; i++) {
^
v.c: In function ‘map_get’:
v.c:3372:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < m.entries.len; i++) {
^
v.c: In function ‘v_map_print’:
v.c:3391:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < m.entries.len; i++) {
^
v.c: In function ‘map_string_str’:
v.c:3409:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp27 = 0; tmp27 < tmp26.len; tmp27++) {
^
v.c: In function ‘smap_get’:
v.c:3446:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < m.entries.len; i++) {
^
v.c: In function ‘smap_str’:
v.c:3530:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp20 = 0; tmp20 < tmp19.len; tmp20++) {
^
v.c: In function ‘os__init_os_args’:
v.c:3569:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < argc; i++) {
^
v.c: In function ‘os__read_file_into_ulines’:
v.c:3677:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp12 = 0; tmp12 < tmp11.len; tmp12++) {
^
v.c: In function ‘new_cgen’:
v.c:4591:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < 10; i++) {
^
v.c: In function ‘CGen_register_thread_fn’:
v.c:4757:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp13 = 0; tmp13 < tmp12.len; tmp13++) {
^
v.c: In function ‘V_prof_counters’:
v.c:4777:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp18 = 0; tmp18 < tmp17.len; tmp18++) {
^
v.c:4789:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp21 = 0; tmp21 < tmp20.len; tmp21++) {
^
v.c:4794:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp23 = 0; tmp23 < tmp22.len; tmp23++) {
^
v.c: In function ‘Parser_print_prof_counters’:
v.c:4814:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp27 = 0; tmp27 < tmp26.len; tmp27++) {
^
v.c:4830:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp31 = 0; tmp31 < tmp30.len; tmp31++) {
^
v.c:4835:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp33 = 0; tmp33 < tmp32.len; tmp33++) {
^
v.c: In function ‘Fn_find_var’:
v.c:4895:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp2 = tmp1; tmp2 < f->var_idx; tmp2++) {
^
v.c: In function ‘Fn_mark_var_used’:
v.c:4946:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp11.len; i++) {
^
v.c: In function ‘Parser_fn_decl’:
v.c:5525:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp51 = 0; tmp51 < tmp50.len; tmp51++) {
^
v.c: In function ‘Parser_async_fn_call’:
v.c:5591:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp58.len; i++) {
^
v.c: In function ‘Parser_fn_args’:
v.c:5861:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp80 = 0; tmp80 < tmp79.len; tmp80++) {
^
v.c: In function ‘Parser_fn_call_args’:
v.c:5960:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp84.len; i++) {
^
v.c:6127:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp95 = 0; tmp95 < tmp94.len; tmp95++) {
^
v.c: In function ‘contains_capital’:
v.c:6204:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < s.len; i++) {
^
v.c: In function ‘Fn_typ_str’:
v.c:6225:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp105.len; i++) {
^
v.c: In function ‘Fn_str_args’:
v.c:6253:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp107.len; i++) {
^
v.c:6265:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp110 = 0; tmp110 < tmp109.len; tmp110++) {
^
v.c: In function ‘Parser_gen_json_for_type’:
v.c:6422:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp11 = 0; tmp11 < tmp10.len; tmp11++) {
^
v.c: In function ‘V_compile’:
v.c:6629:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp6 = 0; tmp6 < tmp5.len; tmp6++) {
^
v.c:6760:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp11 = 0; tmp11 < tmp10.len; tmp11++) {
^
v.c:6859:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp16 = 0; tmp16 < tmp15.len; tmp16++) {
^
v.c:6884:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp18 = 0; tmp18 < tmp17.len; tmp18++) {
^
v.c: In function ‘V_cc’:
v.c:6980:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp30 = 0; tmp30 < tmp29.len; tmp30++) {
^
v.c: In function ‘V_v_files_from_dir’:
v.c:7135:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp50 = 0; tmp50 < tmp49.len; tmp50++) {
^
v.c: In function ‘V_add_user_v_files’:
v.c:7229:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp61 = 0; tmp61 < tmp60.len; tmp61++) {
^
v.c:7252:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp64 = 0; tmp64 < tmp63.len; tmp64++) {
^
v.c:7263:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < c->table->imports.len; i++) {
^
v.c:7273:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp72 = 0; tmp72 < tmp71.len; tmp72++) {
^
v.c:7285:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < c->table->imports.len; i++) {
^
v.c:7295:7: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp80 = 0; tmp80 < tmp79.len; tmp80++) {
^
v.c:7315:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp83 = 0; tmp83 < tmp82.len; tmp83++) {
^
v.c:7332:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp87 = 0; tmp87 < tmp86.len; tmp87++) {
^
v.c:7341:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp90 = 0; tmp90 < tmp89.len; tmp90++) {
^
v.c: In function ‘new_v’:
v.c:7525:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp111 = 0; tmp111 < tmp110.len; tmp111++) {
^
v.c: In function ‘Parser_parse’:
v.c:7899:9: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = start; i < end; i++) {
^
v.c: In function ‘Parser_dot’:
v.c:9948:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp142 = 0; tmp142 < tmp141.len; tmp142++) {
^
v.c:9958:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp144 = 0; tmp144 < tmp143.len; tmp144++) {
^
v.c: In function ‘Parser_assoc’:
v.c:10920:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp201 = 0; tmp201 < tmp200.len; tmp201++) {
^
v.c: In function ‘Parser_struct_init’:
v.c:11511:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp240.len; i++) {
^
v.c:11559:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp244.len; i++) {
^
v.c: In function ‘Parser_js_decode’:
v.c:12673:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp311 = 0; tmp311 < tmp310.len; tmp311++) {
^
v.c: In function ‘is_compile_time_const’:
v.c:12757:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp319 = 0; tmp319 < tmp318.len; tmp319++) {
^
v.c: In function ‘Type_str’:
v.c:13752:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp3 = 0; tmp3 < tmp2.len; tmp3++) {
^
v.c:13767:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp5 = 0; tmp5 < tmp4.len; tmp5++) {
^
v.c: In function ‘Table_register_fn’:
v.c:13950:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp13 = 0; tmp13 < tmp12.len; tmp13++) {
^
v.c: In function ‘Table_known_type’:
v.c:13972:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp16 = 0; tmp16 < tmp15.len; tmp16++) {
^
v.c: In function ‘Table_find_fn’:
v.c:13988:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp18 = 0; tmp18 < tmp17.len; tmp18++) {
^
v.c: In function ‘Table_known_fn’:
v.c:14018:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp20 = 0; tmp20 < tmp19.len; tmp20++) {
^
v.c: In function ‘Table_register_type’:
v.c:14046:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp23 = 0; tmp23 < tmp22.len; tmp23++) {
^
v.c: In function ‘Table_register_type_with_parent’:
v.c:14094:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp28 = 0; tmp28 < tmp27.len; tmp28++) {
^
v.c: In function ‘Table_register_type2’:
v.c:14127:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp32 = 0; tmp32 < tmp31.len; tmp32++) {
^
v.c: In function ‘Type_find_field’:
v.c:14172:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp38 = 0; tmp38 < tmp37.len; tmp38++) {
^
v.c: In function ‘Type_find_method’:
v.c:14250:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp48 = 0; tmp48 < tmp47.len; tmp48++) {
^
v.c: In function ‘Table_find_type’:
v.c:14309:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < tmp51.len; i++) {
^
v.c: In function ‘Parser_satisfies_interface’:
v.c:14501:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp57 = 0; tmp57 < tmp56.len; tmp57++) {
^
v.c: In function ‘Table_is_interface’:
v.c:14568:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp59 = 0; tmp59 < tmp58.len; tmp59++) {
^
v.c: In function ‘Table_main_exists’:
v.c:14584:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp61 = 0; tmp61 < tmp60.len; tmp61++) {
^
v.c: In function ‘Table_find_const’:
v.c:14600:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp63 = 0; tmp63 < tmp62.len; tmp63++) {
^
v.c: In function ‘build_keys’:
v.c:14731:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int t = (/*casttt*/ (int)(/*77*/ keyword_beg)) + 1;
^
v.c: In function ‘array_Token_contains’:
v.c:15060:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int tmp110 = 0; tmp110 < tmp109.len; tmp110++) {
^
About my system:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.11 (jessie)
Release: 8.11
Codename: jessie
$ gcc --version
gcc (Debian 4.9.2-10+deb8u2) 4.9.2
Fixed it!
Rather than
$ cc -w -o vc v.c
run
$ cc -std=c99 -w -o vc v.c
one quick note, cc and gcc point to the same executable 99% of the time. there's usually no difference
@catastrop says to use
$ cc -std=c11 -w -o vc v.c
which also compiles for me :+1: .
@catastrop Any comments you want to add on why c11 mode is better/best? Thanks.
@elimisteve c11 is a newer version of the c standard. that's the only difference
Have the official build instructions changed to accommodate this? If not,
then this should stay open, methinks.
On Saturday, June 22, 2019, Rainbow notifications@github.com wrote:
this issue can be closed
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.<
https://ci4.googleusercontent.com/proxy/xu_2B3c48xHL9psL8gRKX0mDdQcOqrAYzdhR1N6L7y_mxdiX27hVfKHI_43q6U6AKdPvu3fxRAeeguumI7ZYW3kw6xuVOG04XAP3eEd79u_go2uNQrRlg-C8Q3HTg906K3qbcqjAwxejKBPoh6mdIltPToFoSk4CqlnmzKVVke13zOBAb1t0s_mdGn0EzWyuY64m59ftARgVizC5dUnqyTvCaLOlHQv6Xfkdhz8fdg=s0-d-e1-ft#https://github.com/notifications/beacon/AABCCU5OXDTGM5NTKDUT5Z3P34IQLA5CNFSM4H2X7V2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYKXS6I.gif>
Fixed.
Most helpful comment
@elimisteve
c11is a newer version of the c standard. that's the only difference