为什么我不能有一个不安全的易失性指针,只有在 AdHoc 模式下?

Why can't I have an unsafe volatile pointer, only in AdHoc mode?

我使用 xamarin.iOS 在 c# 中使用 CoreAudio 编写了一个低级音频播放器。

在其中一个 类 中,我有两个 volatile 指针,方式如下:

public unsafe volatile short* readPointer;
public unsafe volatile short* writePointer;

整个程序编译并运行良好。

我还设置了一个 Jenkins 构建机器,因此它会在我的项目文件上调用 mdtool 以在 AdHoc 模式下构建它。但是,当我以这种方式构建时,出现以下错误:

Build complete -- 2 errors, 0 warnings
MixerChannel.cs(21,39) : error CS0677: `MixerChannel.readPointer': A volatile field cannot be of the type `short*'
MixerChannel.cs(22,39) : error CS0677: `MixerChannel.writePointer': A volatile field cannot be of the type `short*'

根据 MSDN,我可以创建 volatile 以下类型的字段:

但这个错误似乎另有说明。

Jenkins 构建机器与我用来构建调试的机器完全相同。但是,构建过程不同:为了调试,我使用 xamarin 构建主机,并从 Windows 框中构建 Visual Studio 2010。对于 Jenkins 构建,我使用 mdtool 使用 plink.

从同一个 Window 框远程调用

我是不是遗漏了什么明显的东西?我坚信 compiler writers are demigods, and therefore any error is almost surely 在我自己的代码中而不是在编译器中。

请参阅此 https://bugzilla.xamarin.com/show_bug.cgi?id=23770 错误报告及其状态。

看来编译器编写者虽然是半神,但有时仍然会犯错误(在这种情况下是在 mono 编译器中)。

一般来说,他们要么迅速纠正这些错误,要么用闪电击中任何提到错误的人。

但是,你很幸运。这个问题应该在 Mono 3.12 中得到修复。所以检查你的版本并升级。