Search code examples
c++function-pointersimplicit-conversionfunction-call

C++ cast with additional round brackets


What does the following statement do in C++?

(*JImageGetResource)(jimage, location, val, size);

This instruction is taken from here.


Solution

  • There's no cast involved. JImageGetResource is a pointer, by adding * in front of it, it will be dereferenced. Typically you will see this with iterators for example.

    In your case it's a function pointer. So the resulting code would be the same as resultingFunction(jimage, location, val, size).

    In line 1017: JImageGetResource = CAST_TO_FN_PTR(JImageGetResource_t, dll_lookup(handle, "JIMAGE_GetResource", path));