Pregunta

Please have a look at the following code

with text_io;
use text_io;

procedure hello is

begin
put_line("hello");
new_line(3);
end hello;

When I click "build all" in GPS IDE, I get this error

gnatmake -d -PC:\Users\yohan\firstprogram.gpr
firstprogram.gpr:1:06: literal string expected
firstprogram.gpr:2:01: "end" expected
gnatmake: "C:\Users\yohan\firstprogram.gpr" processing failed

[2013-04-03 13:29:58] process exited with status 4 (elapsed time: 00.47s)

I am very new to Ada, as you can see, this is my first program. Please help.

¿Fue útil?

Solución

On the command line, gnatmake will happily compile a file which contains Ada code but has the extension .gpr. GPS knows "better" than that, and insists on treating myfirstprogram.gpr as a GNAT Project file, which of course it isn't.

You'll find life with GNAT much easier if you stick with its file naming conventions: .ads for a spec, .adb for a body, and the file name needs to be the unit name in lower case. In your case, the file should have been called hello.adb.

The simplest approach to creating a GNAT project file in GPS is to go to the Project menu and select New. The only places where you must enter data are on the "Naming the project" page (you might choose firstproject!) and the "Main files" page, where you'd click on the blue + to add hello.adb; you can Forward through the others.

After adding the main file, you can click Apply to install the new project file; now you can Build all and Run.

You may find the GPS tutorial helpful (Help menu, GPS ...)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top