Click here to Skip to main content
15,917,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
int function_name ( char *filename, int *fildsptr, int *mode, int *dirperms, int *reclen, int *filefmt )
.
.
.
C#
HANDLE hFile;
.
.
.
C#
*fildsptr = SETFD(hFile);  <--- offending line of code 



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.
Posted
Updated 5-Oct-11 8:25am
v4
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 13:56pm    
What is ';)' a smile or what? :-) The code would not compile just due to this, anyway...
--SA
Timberbird 5-Oct-11 14:17pm    
Is SETFD a function or a macros? If it is macros, find and check its body, maybe include it in your question

1 solution

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:

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

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


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
 
Share this answer
 
v4
Comments
Espen Harlinn 5-Oct-11 15:22pm    
5'ed!
Sergey Alexandrovich Kryukov 5-Oct-11 15:50pm    
Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900