c - (*Read)(void *p, void *buf, size_t *size); 中返回类型的含义

标签 c pointers visual-studio-2013 void return-type

我正在使用 VS 2013 和 c 处理现有项目。

我来到这个函数,但我不明白它是什么意思:

  int (*Read)(void *p, void *buf, size_t *size);

我所知道的是它是一个返回指向 int 的指针的函数,但我想知道:

  1. Why void as type means when dealing with parameters (maybe a generic pointer ?)
  2. What (*Read) means in this case (i think it's a cast !)

要真正知道我在这里使用的是完整的依赖项:

typedef struct
{
  #ifdef USE_WINDOWS_FILE
  HANDLE handle;
  #else
  FILE *file;
  #endif
} CSzFile;

typedef struct
{
  int (*Read)(void *p, void *buf, size_t *size);
} ISeqInStream;

typedef struct
{
  ISeqInStream s;
  CSzFile file;
} CFileSeqInStream;

 CFileSeqInStream inStream;

最终目标是打开一个文件,但为什么要这么复杂!

任何帮助将不胜感激,谢谢。

最佳答案

What i know is it's a function that return pointer to int

不,它是指向函数的指针,将以下参数类型作为输入:

  • 第一个参数的类型:void*
  • 第二个参数的类型:void*
  • 第三个参数的类型:size_t*

并返回一个 int 值作为输出。

关于c - (*Read)(void *p, void *buf, size_t *size); 中返回类型的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35197699/

相关文章:

c - 是否保证全局变量总是用c99初始化为0?

c - 调试无效的 free()

c - 使用指针返回数组的总和 - 无输出

Python从内部函数更改外部字典

c++ - 了解 C4673 编译器警告

.net - System.Security.Cryptography.X509Certificates.X509Certificate2 在目标框架版本中不可用

c# - VS 2013 脚手架中的 "There was an error running the selected code generator"

c++ - 带有 cvfilter2d 的 opencv。我越来越黑了图片

c - 如何在C中生成名称长度为X的文件?

在没有运行 Wireshark 的情况下无法在 C 中嗅探 UDP 数据包