gnat - What caused this Ada compilation error "ambiguous character literal"? -


i have ada code.

with ada.text_io;  use ada.text_io;  procedure for_loop begin     counter in 'a'..'z' loop         put(counter);        end loop;     new_line; end for_loop; 

the ada compiler (gnatmake) outputs these error message.

gcc -c for_loop.adb for_loop.adb:6:24: ambiguous character literal for_loop.adb:6:24: possible interpretation: character for_loop.adb:6:24: possible interpretation: wide_character for_loop.adb:6:24: possible interpretation: wide_wide_character gnatmake: "for_loop.adb" compilation error 

what's wrong code?

from post https://gcc.gnu.org/onlinedocs/gnat_rm/legal-ada-83-programs-that-are-illegal-in-ada-95.html:

the problem 'a' , 'z' either character or wide_character. simplest correction make type explicit; e.g.: char in character range 'a' .. 'z' loop ... end loop;

with ada.text_io;  use ada.text_io;  procedure for_loop begin     counter in character range 'a'..'z' loop         put(counter);        end loop;     new_line; end for_loop; 

this oupput:

abcdefghijklmnopqrstuvwxyz 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -