小编Sim*_*ght的帖子

为什么Ada中没有多重或阻止评论?

为什么在Ada编程中没有像C/C++那样的多重或块注释/* */

comments ada

9
推荐指数
1
解决办法
4372
查看次数

从源代码编译cpabe包时链接gmp时出错

我最后花了几个小时从Ubuntu 12.10中的源代码编译cpabe包,其中包含gmp和pbc依赖项.以下错误消息似乎是Web中许多人的问题(即使编译其他需要安装libgmp作为依赖项的软件包!).然而,我找不到任何可行的解决方案:

...
/usr/bin/ld: /usr/local/lib/libpbc.so: undefined reference to symbol '__gmpz_init'
/usr/bin/ld: note: '__gmpz_init' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libgmp.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libgmp.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

ubuntu linker compilation gmp

8
推荐指数
1
解决办法
3458
查看次数

ADA - 以编程方式将 VoiceOver 焦点转移到另一个 SwiftUI 视图 - 与 IOS 13+ 兼容

概述:

我很难理解如何在与 IOS 13+ 兼容的SwiftUI 视图中以编程方式正确转移辅助功能焦点。

不幸的是,这意味着无法使用 IOS 15+ 中提供的较新的 SwiftUI 焦点管理 API。

我看到的大多数建议与以下帖子类似:

iOS 更改辅助功能焦点。

它建议使用UIAccessibility.post(notification: .screenChanged/layoutChanged) argument: View)来更改焦点

然而,我的尝试没有成功。

我已经能够以与下面的代码相同的方式成功使用UIAccessibility.post(notification: .announcement) argument: String),并且它确实按预期宣布了刺痛。它花费的时间比 asyncAfter 计时器要长得多(可能需要 8 秒),但它似乎表明 post() 调用正在工作。

代码示例:

自定义展开/折叠,带有 V 形向上或向下,具体取决于它是展开还是折叠。

我希望能够以编程方式控制焦点扩展时的位置。例如,我可能希望能够让 VoiceOver 聚焦在打开的扩展菜单中的“菜单项 3”上。

我认为接近下面代码的东西可能会起作用,但我对帖子中的参数视图如何工作缺乏了解,并且不确定是否有办法使用 SwiftUI 视图,或者我是否需要创建一个UIKit 视图并使用 UIViewRepresentable 或使用 UIHostingController 包装它?

目前的行为

展开菜单时,VoiceOver 会移至第一项。当菜单折叠时,VoiceOver 焦点将转移到最后一个文本视图。

期望的行为

我希望能够在展开菜单时明确决定 VoiceOver 焦点的位置,并能够在视图出现时将更多焦点集中到特定视图

我还考虑了使用 SwiftUI/IOS 13+ 中提供的工具的其他方法。例如,我使用accessibility(sortPriority:)和accessibilityElement(children: .combine/.contain/.ignore)来达到预期的结果,但这些努力也被证明是不成功的。

代码搜索:

以下 GitHub 搜索目前分别产生 10 和 13 个结果:

https://github.com/search?q=UIAccessibility.post%28notification%3A+.layoutChanged+View+%22import+swiftui%22&type=code

https://github.com/search?q=UIAccessibility.post%28notification%3A+.screenChanged+View+%22import+swiftui%22&type=code

在这些结果中,SwiftUI 视图中使用的结果使用了“nil”参数(据说将焦点转移到屏幕上的第一项)

这让我怀疑我是否真的偏离了轨道。 …

accessibility uikit ios voiceover swiftui

7
推荐指数
1
解决办法
3477
查看次数

非本地指针不能指向本地对象

为什么以下行为会像它的行为一样:

\n
with Interfaces.C;\nwith Interfaces.C.Strings;\nprocedure X is\n\n   type Integer_Access is access all Integer;\n\n   Arr_Access : Interfaces.C.Strings.char_array_access;\n   Arr : aliased Interfaces.C.char_array := Interfaces.C.To_C ("From");\n\n   A : Integer_Access;\n   I : aliased Integer := 6;\n\nbegin\n\n   Arr_Access := Arr\xe2\x80\x99Access;  -- not OK\n   A := I\xe2\x80\x99Access;             -- OK\n\nend X;\n
Run Code Online (Sandbox Code Playgroud)\n

结果:

\n
$ gnatmake x.adb \ngcc -c x.adb\nx.adb:16:18: non-local pointer cannot point to local object\ngnatmake: "x.adb" compilation error\n
Run Code Online (Sandbox Code Playgroud)\n

Arr和不Arr_Access具有相同的可访问性级别吗?

\n

ada

6
推荐指数
1
解决办法
1903
查看次数

如何激活Finalize的多个调用?

在最近的AdaCore Gem中有一个声明

Finalize的实现稍微复杂一些:Ada参考手册表明Finalize过程应该始终是幂等的.Ada编译器可以在同一对象上多次调用Finalize,特别是在发生异常时.

我需要测试一个私人控制类型,

   type T is private;
private
   type T is new Ada.Finalization.Controlled with ...
Run Code Online (Sandbox Code Playgroud)

我可以更改源以使类型明显受控制

   type T is new Ada.Finalization.Controlled with private;
Run Code Online (Sandbox Code Playgroud)

然后只是打电话Finalize (My_T);(甚至My_T.Finalize?); 但有没有什么方法可以导致多次最终确定而不对测试中的软件进行此更改?

ada finalize

5
推荐指数
1
解决办法
213
查看次数

在GPS IDE中调试

我正在使用GPS IDE进行Ada 95编码.当我尝试在.adb文件中放置一个断点时,我收到一条消息"没有名为filename.adb的源文件".我构建了项目并初始化了调试器.什么可能出错?

奇怪的是,我能够执行该程序.

ada gnat-gps

5
推荐指数
1
解决办法
1735
查看次数

Ada中的绑定与链接

我想知道在使用Ada代码时绑定和链接之间的根本区别是什么?我在谷歌上找不到一个好的解释,这就是为什么我问这个问题.

对于绑定过程,输入是什么,输出是什么?绑定和链接之间有什么关系?我认为首先需要进行绑定.

谢谢,波格丹.

ada gnat

5
推荐指数
2
解决办法
284
查看次数

在GDB Python脚本中,如果框架的语言为Ada,则数组索引编制将失败

我有一个脚本可以计算出每个FreeRTOS任务中有多少可用堆栈空间。GDB的语言设置为auto。当当前语言为时c,脚本可以正常工作,但是当当前语言为时,脚本将失败ada

我,在班上Stacks

tcb_t = gdb.lookup_type("TCB_t")
int_t = gdb.lookup_type("int")
Run Code Online (Sandbox Code Playgroud)

过去曾:

找到{Ada任务控制块} .Common.Thread,

thread = atcb["common"]["thread"]
Run Code Online (Sandbox Code Playgroud)

转换为指向FreeRTOS任务控制块的指针,

tcb = thread.cast(Stacks.tcb_t.pointer()).dereference()
Run Code Online (Sandbox Code Playgroud)

找到堆栈的逻辑顶部

stk = tcb["pxStack"].cast(Stacks.int_t.pointer())
Run Code Online (Sandbox Code Playgroud)

现在,我需要在逻辑上向下循环堆栈,直到找到与初始化值不相等的条目为止,

free = 0
while stk[free] == 0xa5a5a5a5:
    free = free + 1
Run Code Online (Sandbox Code Playgroud)

如果当前帧的语言是工作正常c,但如果这是ada我得到的

Python异常<class'gdb.error'>不是数组或字符串:Python命令中发生错误:不是数组或字符串

我已经将其追溯到表达式stk[free],该表达式使用当前语言的规则进行解释(在Ada中,数组索引使用括号,因此它将是stk(free),这当然是非法的,因为Python将其视为函数调用)。

我已经为此工作了

def invoke(self, arg, from_tty):
    gdb.execute("set language c")
    ...
    gdb.execute("set language auto")
Run Code Online (Sandbox Code Playgroud)

但是,如果不将语言重新设置为原来的语言,这似乎是错误的。

所以,

  • 有没有一种方法可以从Python中检测当前的GDB语言设置?
  • 是否有不依赖于当前GDB语言设置的替代索引方式?

ada freertos gdb-python

5
推荐指数
0
解决办法
78
查看次数

我应该怎么做才能解决 GNAT GPS“未找到库”问题并在我的 Mac 上构建我的第一个“Hello World”程序?

我下载了 GNAT Community 2019 并安装在我的 Mac 上的主文件夹“/Users/leon/opt/GNAT”中

我在目录“/Users/leon/opt/GNAT/2019/bin”中运行命令“gps”。GPS出现了,然后我创建了一个项目,输入了“Hello World”代码。正如维基教科书所示。

with Ada.Text_IO;

procedure Hello is
begin
   Ada.Text_IO.Put_Line("Hello, world!");
end Hello;
Run Code Online (Sandbox Code Playgroud)

当我单击构建按钮时,程序无法构建。

以下是建筑输出。

gprbuild -d -P/Users/leon/Documents/ada/helloworld.gpr /Users/leon/Documents/ada/src/hello.adb
Compile
   [Ada]          hello.adb
Bind
   [gprbind]      hello.bexch
   [Ada]          hello.ali
Link
   [link]         hello.adb
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
gprbuild: link of hello.adb failed
gprbuild: failed command was: /users/leon/opt/gnat/2019/bin/gcc hello.o b__hello.o -L/Users/leon/Documents/ada/obj/ -L/Users/leon/Documents/ada/obj/ -L/users/leon/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/leon/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/libgnat.a -Wl,-rpath,@executable_path/ -Wl,-rpath,@executable_path/../../..//opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib -o hello
[2020-02-28 22:36:48] process exited with status 4, elapsed time: …
Run Code Online (Sandbox Code Playgroud)

ada gnat gnat-gps

5
推荐指数
1
解决办法
436
查看次数

使用递归的 Ada 斐波那契数列

在这段代码中,我试图编写一个程序,根据用户的输入(索引、大小)打印出斐波那契数列。然后,程序应该打印出 Index..Size 之间的所有斐波那契数。我在编写一个计算并打印出斐波那契数列的递归时遇到了麻烦。有什么建议?

with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO, Ada.Unchecked_Deallocation;

procedure Fibonacci is
   type Arr is array (Positive range <>) of Integer;
   type Array_Access is access Arr;
   Size, Index : Positive;
   Variable    : Array_Access;
   procedure Free is new Ada.Unchecked_Deallocation (Arr, Array_Access);

   procedure Recursion (Item : Arr) is                  --Recursion
   begin
      Put_Line
        (Item (Item'First)'Image);                   --Prints out the numbers
      Recursion
        (Item
           (Item'First + Item'First + 1 ..
                Item'Last));     --Calculating the Fibonacci numbers
   end Recursion;

begin
   Put ("Welcome to the …
Run Code Online (Sandbox Code Playgroud)

ada

5
推荐指数
2
解决办法
302
查看次数