涉及SETFD函数的编译错误C2296 [英] compile error C2296 involving SETFD function

查看:177
本文介绍了涉及SETFD函数的编译错误C2296的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找&"使我在包含文件中发现了一个问题,该问题使我回到了项目中的预处理器设置.问题已解决-谢谢.


我正在Developer Studio中(编译为C代码(/TC))编译未经修改的旧C源代码(作者未知),但出现编译错误
错误C2296:&":非法,左操作数的类型为"HANDLE""
适用于以下代码:

Hunting down the "&" led me to find an issue in an include file which led me back to the preprocessor settings in the project. Problem solved - thank you.


I am compiling old, unmodified C source code (author unknown) in Developer Studio (Compile as C Code (/TC)) and I get the compile error
"error C2296: ''&'' : illegal, left operand has type ''HANDLE''"
for the following code:

int function_name ( char *filename, int *fildsptr, int *mode, int *dirperms, int *reclen, int *filefmt )

.
.
.

.
.
.

HANDLE hFile;

.
.
.

.
.
.

*fildsptr = SETFD(hFile);  <--- offending line of code 




我不确定为什么当定义为"int *"的输入参数时,左操作数的类型为"Handle".我在SETFD上搜索Google,以为这是一个涉及文件描述符的rtn系统,但对此却知之甚少.

不知道如何回答提交了答案的人,因此我已根据您的担忧修改了问题.
谢谢.




I''m not sure why it says the left operand has a type of "Handle" when it is an input argument defined as "int *". I googled SETFD thinking it was a system rtn involving a file descriptor but found little to nothing about it.

Not sure how to reply to those who have submitted an answer so I have modified the question in response to your concerns.
Thank you.

推荐答案

您当然只是不显示真实令人反感的代码.这里出了点问题.
错误消息表明&"是两个操作数之间的中缀运算符,并且左操作数具有不兼容的类型.如果这确实是C而不是C ++(我不能百分百确定),则此运算符只能是按位AND运算符(并且这不是逻辑上的``&&'').

因此,寻找这样的代码:

You certainly simply did not show real offending code. Something''s wrong here.
The error message suggests the ''&'' is an infix operator between two operands, and that the left operand has incompatible type. If this is really C and not C++ (which I cannot be 100% sure), this operator could be only the bitwise AND operator (and this is not logical ''&&'').

So, look for code like this:

/* b declaration? */
/* ... */
HANDLE h;

/*...*/ a = h & b;



您的代码示例甚至不包含&".显示代码行和代码格式可能有问题.

希望它能给您有关该问题的提示.毕竟,使用全局文本搜索并找到"HANDLE"和&".

—SA



Your code sample does not even contain ''&''. Something is wrong with showing the code lines and probably with formatting of the code.

Hope it will give you a hint about the problem. After all, use global text search and find HANDLE and ''&''.

—SA


这篇关于涉及SETFD函数的编译错误C2296的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆