Pelles C forum

C language => Beginner questions => Topic started by: bitcoin on April 17, 2020, 12:04:39 PM

Title: How to convert C++ operator to C?
Post by: bitcoin on April 17, 2020, 12:04:39 PM
Hello
I have trouble with C++ operator &

How to convert code to C. Such as:

Code: [Select]
DetourDetach(&(PVOID&)TrueMessageBoxA, MyMessageBoxA);
This don't compile with C and don't work without ampserdants. (lib is Microsoft Detours)
Title: Re: How to convert C++ operator to C?
Post by: frankie on April 17, 2020, 03:39:22 PM
This case ampersand in C++ means a reference to a variable. In C it behaves like a pointer.
But be careful: a reference is not a pointer in C++ (don't say something like that on stackoverflow or you'll get strongly and continuosly downvoted  ;D ;D ;D ;D ;D People don't read the contest just outline the first thing seemingly strange at them  ;D ;D ;D ;D)
The code is to be translated as:
Code: [Select]
DetourDetach(&TrueMessageBoxA, MyMessageBoxA);