Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 在非结构或联合中请求成员“\u文件”_C_Pointers_Struct_Unions - Fatal编程技术网

C 在非结构或联合中请求成员“\u文件”

C 在非结构或联合中请求成员“\u文件”,c,pointers,struct,unions,C,Pointers,Struct,Unions,我得到了这个错误: somedir/somefile.c: In function 'somefunc': somedir/somefile.c:433:33: error: request for member '_file' in something not a structure or union ReturnValue->Val->Integer = _fileno(Param[0]->Val->Pointer);

我得到了这个错误:

somedir/somefile.c: In function 'somefunc':
somedir/somefile.c:433:33: error: request for member '_file' in something not a 
structure or union
     ReturnValue->Val->Integer = _fileno(Param[0]->Val->Pointer);
                                 ^
尝试编译下一个代码时:

void somefunc(struct p *P, struct Value *ReturnValue, struct Value **Param, int n)
{
    ReturnValue->Val->Integer = _fileno(Param[0]->Val->Pointer);
}
ReturnValue是指向结构值的指针,其中有一个指向union的指针,union中有int Integer

Param的工作原理也类似。我的意思是,一切看起来都是正确的,因为我还有另外一个函数,像这个,我没有任何错误,只有这个。发生了什么?它是否与_fileno函数相关?当我将_fileno更改为fileno时也会发生同样的情况。

\u filno在本例中被定义为宏;展开宏时,会尝试取消引用指针参数并访问_文件成员,例如arg->_文件。但是,这将失败,因为您无法遵从void*

指针应为FILE*类型,或从有效的FILE*对象分配,然后在传递到_fileno:

_在本例中,filno被定义为宏;展开宏时,会尝试取消引用指针参数并访问_文件成员,例如arg->_文件。但是,这将失败,因为您无法遵从void*

指针应为FILE*类型,或从有效的FILE*对象分配,然后在传递到_fileno:

Param[0]->Val->Pointer是文件吗?在您提供的声明中,我没有看到任何名为Pointer的成员。没有函数:\u fileno也许您的意思是:fileno@user3629249\u fileno是一个MSVC函数,他们认为fileno是参数[0]->Val->Pointer文件?在您提供的声明中,我没有看到任何名为Pointer的成员。没有函数:\u fileno也许您的意思是:fileno@user3629249\u fileno是MSVC函数,他们以自己的智慧反对fileno。
union SomeValue
{
    int Integer;
    void *Pointer;
}

struct Value
{
    union SomeValue *Val;
}
ReturnValue->Val->Integer = _fileno( (FILE*)Param[0]->Val->Pointer ) ;