任务定义中的非法声明 [英] Illegal declaration in task definition

查看:65
本文介绍了任务定义中的非法声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下任务说明:

with Ada.Real_Time; use Ada.Real_Time;

package pkg_task is
    task type task_t is
        activationTime : constant Integer := 1;
        period : constant Integer := 2;
        computingTime : constant Integer := 1;
        startingTime : Time;
    end task_t;
end pkg_task;

编译时,我在声明变量的任务说明的所有行中都获得了标题中提到的错误,而我不知道出了什么问题.

When I compile I obtain the error mentioned on the title in all the lines of the task specification where I declare the variables, and I don't know what is the problem.

推荐答案

正如Jacob所写的,您不能导出任务中不是条目的任何内容. 在这种情况下,您的任务非常简单

As Jacob wrote, you can't export anything that is not an entry in tasks. In this case, your task is really straightforward

package pkg_task is
   task type task_t;
end pkg_task;

然后,您可以在体内使用变量.

In the body, you can then use your variables.

package body pkg_task is

   task body task_t is
      Activation_Time : constant Integer := 1;
      Period          : constant Integer := 2;
      Computing_Time  : constant Integer := 1;
      -- Starting_Time   : Time;
   begin
      null;
   end task_t;
end pkg_task;

无论如何,如果您向我们解释了您要做什么,将会更容易.

Anyway, it would be easier if you explained us what you're trying to do.

这篇关于任务定义中的非法声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆