NO

Author Topic: How to convert C++ operator to C?  (Read 1958 times)

Offline bitcoin

  • Member
  • *
  • Posts: 179
How to convert C++ operator to C?
« 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)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: How to convert C++ operator to C?
« Reply #1 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);
« Last Edit: April 17, 2020, 03:48:25 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide