如何使用指向c#中指针的指针?

如何使用指向c#中指针的指针?,c#,pointers,ffmpeg,C#,Pointers,Ffmpeg,我正在使用Visual Studio 2012中的C#调用项目所需的一组外部库中包含的函数。该函数需要传入一个双指针,但我不确定确切的语法。单指针对我来说很有用。我正在使用不安全的关键字 AVFormatContext _file = new AVFormatContext(); fixed (AVFormatContext* p_file = &_file) { avformat_alloc_output_context2(&p_file,null,null,filen

我正在使用Visual Studio 2012中的C#调用项目所需的一组外部库中包含的函数。该函数需要传入一个双指针,但我不确定确切的语法。单指针对我来说很有用。我正在使用不安全的关键字

AVFormatContext _file = new AVFormatContext();

fixed (AVFormatContext* p_file = &_file)
{
   avformat_alloc_output_context2(&p_file,null,null,filename);
}
VS抱怨“&p_文件”语法错误为“无法获取只读局部变量的地址”


任何帮助都将不胜感激

您不能获取
p\u文件的地址,因为
p\u文件在固定块内是只读的。如果你能记下它的地址,那么这是可能的:

fixed (AVFormatContext* p_file = &_file)
{
   AVFormatContext** ppf = &p_file;
   *ppf = null; // Just changed the contents of a read-only variable!
因此,您必须记下您可以更改的地址:


现在我们都好了;更改
*ppf
不会更改
p\u文件
您不能获取
p\u文件
的地址,因为
p\u文件
在固定块内是只读的。如果你能记下它的地址,那么这是可能的:

fixed (AVFormatContext* p_file = &_file)
{
   AVFormatContext** ppf = &p_file;
   *ppf = null; // Just changed the contents of a read-only variable!
因此,您必须记下您可以更改的地址:


现在我们都好了;更改
*ppf
不会更改
p\u文件

尝试使用
ref
参数声明
avformat\u alloc\u output\u context2
,而不是使用
&
。这也不起作用。错误状态:无法将“p_file”作为ref或out参数传递,因为它是“固定变量”。我认为您没有发布足够的代码。请尝试使用
ref
参数声明
avformat\u alloc\u output\u context2
,而不是使用
&
。这也不起作用。错误状态:无法将“p_file”作为ref或out参数传递,因为它是一个“固定变量”。我认为您没有发布足够的代码。