Definition of function pointer type.
endScene fpEncScene;
fpEncScene = some_addr; // setting
fpEncScene(device); // calling the function
As Daewon said, it's function pointer type definition.
Let me write down a little bit of explanation.
First of all, if you look at the code and the results below, you can easily see how the function pointer type definition is used.
#include <iostream>
using namespace std;
int sum(int a, int b)
{
return a + b;
}
typeef (*p_sum)(inta, intb); // Define function pointer type
int main()
{
p_summy_sum = sum; // Define function pointer variables
cout <<"sum: "<< sum(10, 20) <<'\n'; // Use general function sum
cout <<"my_sum:" << my_sum(10, 20) <<'\n'; // Use function pointer
return 0;
}
When you define a function pointer type as below, you can see that it is a function pointer with a star in front of the function name part and parentheses before and after it, as shown in (*p_sum)
. By looking at the return value at the front of the function name part and the shape of the parameter at the back, you can see that the variable declared with this function pointer type can only store the address of the function with the return value int and the parameter (int, int). A compilation error occurs if the return value and parameter form do not match.
typedef int (*p_sum)(int a, int b);
In the case of the code below you asked, the variable declared as endSene
type can only contain the address value of the function with the return value HRESULT
and the parameter type (IDirect3DDdevice9*)
.
And __stdcall
is like a reserved word to mean that the function is a WINAPI function. It is attached before the WINAPI functions.
typedef HRESULT (__stdcall* endScene)(IDirect3DDevice9* pDevice);
Please refer to the code and the results below. It'll help you understand.
#include <iostream>
#include <Windows.h>
using namespace std;
typedef DWORD (__stdcall* p_name)(LPSTR lpConsoleTitle, DWORD nSize);
int main()
{
p_name my_get_console_title = GetConsoleTitleA;
char str1[80] = { 0, };
char str2[80] = { 0, };
GetConsoleTitleA(str1, 80);
my_get_console_title(str2, 80);
cout << "str1: " << str1 << '\n';
cout << "str2: " << str2 << '\n';
return 0;
}
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
549 PHP ssh2_scp_send fails to send files as intended
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
546 Understanding How to Configure Google API Key
708 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.