oop - cannot generate code for file -


please have @ following code

formula.ads

package formula    procedure calculateformula; end formula; 

formula.adb

with ada.text_io; use ada.text_io; formula; use formula;  package body formula    procedure calculateformula        package fom_io new ada.float_text_io(float);       use fom_io;        u : float;       t : float;       : float;       answer : float;     begin       put_line("enter 'u'");       get(u);        put_line("enter 't'");       get(t);        put_line("enter 'a'");       get(a);        answer = (u*t)+ 0.5(a(t*t));        put("answer is: ");       put(answer,fore => 1,aft => 1,exp => 1);    end calclualeformula; end formula; 

when run code, following error

gnatmake -d -pc:\users\yohan\documents\ada\formula\formula.gpr gcc -c -i- -gnata c:\users\yohan\documents\ada\formula\formula.ads cannot generate code file formula.ads (package spec) gnatmake: "c:\users\yohan\documents\ada\formula\formula.ads" compilation error  [2013-04-06 03:18:22] process exited status 4 (elapsed time: 00.22s) 

i new ada. started coding few hours back. please me rid of above issue. thank you.

edit

formula.gpr

project formula     main use ("formula.ads");  end formula; 

the gpr file shows trying use package specification main program unit - doesn't work.

two ways fix this: simplest 1 make "calculateformula" standalone main program in file "calculateformula.adb" , set in project file:

for main use ("calculateformula.adb"); 

but if want see how packages work, there "better" way (in gets understand packages , how used...)

packages reusable components : package spec need see in order use them ... use them in program. in case create main program

with formula; use formula;      procedure mymain     begin        calculateformula;     end mymain; 

and in .gpr file,

for main use ("mymain.adb"); 

and compiler automatically compile correct packages , find other issues shark has pointed out.

you don't need separate main here, "hello world" example showed. such trivial "main subprograms" (in correct ada lingo) not unusual, purposes unit testing packages used in more complex apps later.


Comments