Conversion of const size_t in mex - c++

I tried to use the yaafe library from http://yaafe.sourceforge.net/manual/install.html. Everything is installed and works fine. However I would like to use the matlab interface and I tried to compile the yaafemex.cpp provided using the following command mex yaafemex.cpp but I have this error on Matlab
Building with 'Xcode Clang++'.
Error using mex
/Users/TMAC/Documents/MATLAB/Add-Ons/Collections/Yaafe/yaafemex.cpp:107:22: error: no matching function for call
to 'mxCreateNumericArray_730'
mxArray* featdata = mxCreateNumericArray(2,dims,mxDOUBLE_CLASS,mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2017a.app/extern/include/matrix.h:1111:30: note: expanded from macro 'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2017a.app/extern/include/matrix.h:782:1: note: candidate function not viable: no known conversion
from 'int [2]' to 'const size_t *' (aka 'const unsigned long *') for 2nd argument
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag);
^
1 error generated.
Portions of code (I haven't changed the intitial code provided by yaafe library)
yaafemex.cpp
/* write data */
int dims[2] = {buf->info().size , buf->availableTokens()};
mxArray* featdata = mxCreateNumericArray(2,dims,mxDOUBLE_CLASS,mxREAL); //line 107
double* featdataPtr = (double*) mxGetData(featdata);
buf->read(featdataPtr,buf->availableTokens());
buf->consumeTokens(buf->availableTokens());
mxSetField(feat,0,"data",featdata);
matrix.h
/*
* Create a numeric array and initialize all its data elements to 0.
*
* Similar to mxCreateNumericMatrix, in a standalone application,
* out-of-memory will mean a NULL pointer is returned.
*/
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag); //line 782
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *
mxCreateNumericArray_700(int ndim, const int *dims, mxClassID classid, mxComplexity flag);

int dims[2] = {buf->info().size , buf->availableTokens()};
Is signed, mxCreateNumericArray expects const size_t *, which is an unsigned numeric type. You either need to explicitly cast dims or define dims with the appropriate type.
Concretely, I'd edit the definition of dims in yaafe as follows:
size_t dims[2] = {static_cast<size_t>(buf->info().size) , static_cast<size_t>(buf->availableTokens())};

Related

Problem with compiling Intel's MKL CBLAS example file on macOS Catalina

I want to solve a problem in C++ which involves finding solutions to a system of equations. I saw that Intel's MKL package provides the necessary tools for that. I have downloaded the entire library and I've installed it.
First, I wanted to see if everything works, so compiling a simple example provided by intel (see the C source file here) was the first thing I've tried. It is a program that multiplies two matrices with the help of cblas_dgem function. However, I get a lot of warnings
and an error:
basavyr#Roberts-MacBook-Pro Desktop % g++ mkl-lab-solution.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from mkl-lab-solution.c:30:
In file included from /usr/local/include/stdio.h:64:
/usr/local/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
unsigned char *_base;
^
/usr/local/include/_stdio.h:93:16: note: insert '_Nullable' if the pointer may be null
unsigned char *_base;
^
_Nullable
/usr/local/include/_stdio.h:93:16: note: insert '_Nonnull' if the pointer should never be null
unsigned char *_base;
^
_Nonnull
/usr/local/include/_stdio.h:138:32: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _read) (void *, char *, int);
^
/usr/local/include/_stdio.h:138:32: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _read) (void *, char *, int);
^
_Nullable
/usr/local/include/_stdio.h:138:32: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _read) (void *, char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:138:40: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _read) (void *, char *, int);
^
/usr/local/include/_stdio.h:138:40: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _read) (void *, char *, int);
^
_Nullable
/usr/local/include/_stdio.h:138:40: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _read) (void *, char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:139:35: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
^
/usr/local/include/_stdio.h:139:35: note: insert '_Nullable' if the pointer may be null
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
^
_Nullable
/usr/local/include/_stdio.h:139:35: note: insert '_Nonnull' if the pointer should never be null
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
^
_Nonnull
/usr/local/include/_stdio.h:140:32: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _write)(void *, const char *, int);
^
/usr/local/include/_stdio.h:140:32: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nullable
/usr/local/include/_stdio.h:140:32: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:140:46: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _write)(void *, const char *, int);
^
/usr/local/include/_stdio.h:140:46: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nullable
/usr/local/include/_stdio.h:140:46: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:144:18: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
^
/usr/local/include/_stdio.h:144:18: note: insert '_Nullable' if the pointer may be null
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
^
_Nullable
/usr/local/include/_stdio.h:144:18: note: insert '_Nonnull' if the pointer should never be null
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
^
_Nonnull
In file included from mkl-lab-solution.c:30:
/usr/local/include/stdio.h:67:13: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern FILE *__stdinp;
^
/usr/local/include/stdio.h:67:13: note: insert '_Nullable' if the pointer may be null
extern FILE *__stdinp;
^
_Nullable
/usr/local/include/stdio.h:67:13: note: insert '_Nonnull' if the pointer should never be null
extern FILE *__stdinp;
^
_Nonnull
/usr/local/include/stdio.h:386:41: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *, const char *, int),
^
/usr/local/include/stdio.h:386:41: note: insert '_Nullable' if the pointer may be null
int (* _Nullable)(void *, const char *, int),
^
_Nullable
/usr/local/include/stdio.h:386:41: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable)(void *, const char *, int),
^
_Nonnull
/usr/local/include/stdio.h:386:55: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *, const char *, int),
^
/usr/local/include/stdio.h:386:55: note: insert '_Nullable' if the pointer may be null
int (* _Nullable)(void *, const char *, int),
^
_Nullable
/usr/local/include/stdio.h:386:55: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable)(void *, const char *, int),
^
_Nonnull
/usr/local/include/stdio.h:387:44: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
fpos_t (* _Nullable)(void *, fpos_t, int),
^
/usr/local/include/stdio.h:387:44: note: insert '_Nullable' if the pointer may be null
fpos_t (* _Nullable)(void *, fpos_t, int),
^
_Nullable
/usr/local/include/stdio.h:387:44: note: insert '_Nonnull' if the pointer should never be null
fpos_t (* _Nullable)(void *, fpos_t, int),
^
_Nonnull
/usr/local/include/stdio.h:388:41: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *));
^
/usr/local/include/stdio.h:388:41: note: insert '_Nullable' if the pointer may be null
int (* _Nullable)(void *));
^
_Nullable
/usr/local/include/stdio.h:388:41: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable)(void *));
^
_Nonnull
/usr/local/include/stdio.h:384:6: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
FILE *funopen(const void *,
^
/usr/local/include/stdio.h:384:6: note: insert '_Nullable' if the pointer may be null
FILE *funopen(const void *,
^
_Nullable
/usr/local/include/stdio.h:384:6: note: insert '_Nonnull' if the pointer should never be null
FILE *funopen(const void *,
^
_Nonnull
mkl-lab-solution.c:85:15: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
print_arr(N,"a", a);
^
mkl-lab-solution.c:86:15: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
print_arr(N,"b", b);
^
mkl-lab-solution.c:87:15: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
print_arr(N,"c", c);
^
16 warnings generated.
Undefined symbols for architecture x86_64:
"_cblas_dgemm", referenced from:
Dgemm_multiply(double*, double*, double*, int) in mkl-lab-solution-96315a.o
ld: symbol(s) not found for architecture x86_64
**clang: error:** linker command failed with exit code 1 (use -v to see invocation)
basavyr#Roberts-MacBook-Pro Desktop %
Compilation was done with the following command: g++ -m64 -I${MKLROOT}/include mkl-lab-solution.c
I am running macOS Catalina (10.15.3). I have no issues with my C++ compiler (I ran everything so far without issues)
Any ideas why is this happening and how can I solve the problem?
You need to link with mkl's libraries. Please refer to the mkl linker adviser to see the list of mkl's libs you need to link. here is the list to this adviser: https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor.

error: invalid conversion from 'void*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

I am trying to import a C library into my C++ project but I'm stuck with this error
invalid conversion from 'void*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]
uint8_t const* raw = static_cast(getPointerToData(id, message->data, message->length));
^
compilation terminated due to -Wfatal-errors.
This code compile well using C compiler but get this error using C++ one
bool XbusMessage_getDataItem(void* item, enum XsDataIdentifier id, struct XbusMessage const* message)
{
uint8_t const* raw = (getPointerToData(id, message->data, message->length));
Can you help me?
Thanks
You need to explicitly cast the return value from getPointerToData to const uint8_t*. Implicit conversions between pointer types are not allowed in C++ but are in C.
Try:
uint8_t const* raw = static_cast<uint8_t const*>(getPointerToData(id, message->data, message->length));
Edit:
You can also use a C-style cast if you want to keep the C code C and not C++.
uint8_t const* raw = (uint8_t const*)(getPointerToData(id, message->data, message->length));
This code posted by Jean-François Fabre works
uint8_t const* raw = (getPointerToData(id, static_cast<const uint8_t*>(message->data), message->length));
Thanks!

Enable conversion between 64 bit integer types

Trying to port some Windows C++ code to Linux + clang.
Here’s a function:
inline __m256i XM_CALLCONV maskload_epi64( const int64_t *mem_addr, __m256i mask )
{
return _mm256_maskload_epi64( mem_addr, mask );
}
Here’s a compiler output:
no matching function for call to '_mm256_maskload_epi64'
return _mm256_maskload_epi64( mem_addr, mask );
^~~~~~~~~~~~~~~~~~~~~
/usr/include/clang/4.0.0/include/avx2intrin.h:989:1: note: candidate function
not viable: no known conversion from 'const int64_t *'
(aka 'const long *') to 'const long long *' for 1st argument
_mm256_maskload_epi64(long long const *__X, __m256i __M)
Is there a compiler switch to make it cast between different 64 bit built-in types without errors?

VL_feat Matlab GCC can't compile [duplicate]

This question already has an answer here:
mex compilation error C2440: 'initializing': cannot convert from 'const mwSize *' to 'const int32_t *'
(1 answer)
Closed 6 months ago.
I was trying to compile the function c_eoverlap in matlab following the instruction here:
http://www.robots.ox.ac.uk/~vgg/research/affine/evaluation.html#eval_soft
Of course, it wouldn't work out... My Matlab version is 2018a which is pretty new and the gcc -v outputs the following
Also attach this long error log, as I am pretty new to C++, please let me know if there is any other information needed, appreciate for your help!
>> mex repeatability/c_eoverlap.cxx
Building with 'Xcode Clang++'.
Error using mex
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:34:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
int const *dims1 = mxGetDimensions(prhs[0]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:36:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
int const *dims2 = mxGetDimensions(prhs[1]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:38:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
int const *dims3 = mxGetDimensions(prhs[2]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:46:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[0] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:47:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[1] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:48:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[2] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:49:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[3] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:198:3: warning: 'delete[]'
applied to a pointer that was allocated with 'new'; did you mean 'delete'?
[-Wmismatched-new-delete]
delete []tdesc_out;
^ ~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:62:22: note: allocated with
'new' here
float *tdesc_out = new float[dims2[1]*dims1[1]];
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:199:3: warning: 'delete[]'
applied to a pointer that was allocated with 'new'; did you mean 'delete'?
[-Wmismatched-new-delete]
delete []tover_out;
^ ~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:63:22: note: allocated with
'new' here
float *tover_out = new float[dims2[1]*dims1[1]];
^
2 warnings and 7 errors generated.
You need to add -compatibleArrayDims to your mex command:
mex -compatibleArrayDims c_eoverlap.cxx
The code is written for older MATLABs that used 32-bit integers (int) for array sizes. Nowadays these are 64-bits (mwSize). This option forces the interface to work like it did in the older MATLABs. See the mex documentation for details.
There are some scary warnings about using delete[] instead of delete. It's just warnings, so it will compile, but you don't know if the code will do what it is supposed to.

build error: none of the 12 overloads could convert all the argument types

I use an overload function that is defined as follows in one of my header files
// indexed variables: todo overloads
extern int PmdgGetVariable(char *variableName, int index, bool* result);
extern int PmdgGetVariable(char *variableName, int index, short* result);
extern int PmdgGetVariable(char *variableName, int index, unsigned short* result);
extern int PmdgGetVariable(char *variableName, int index, int* result);
extern int PmdgGetVariable(char *variableName, int index, unsigned int* result);
extern int PmdgGetVariable(char *variableName, int index, float* result);
I get an error from the build prosess when
trying these arguments
int res = PmdgGetVariable("MCP", 0, 0);
error is
main.cpp(80): error C2665: 'PmdgGetVariable' : none of the 12 overloads could convert all the argument types
1> c:\users\roar\documents\visual studio 2010\projects\iocpclient_ngx v0.3\PmdgSiocConnector.h(27): could be 'int PmdgGetVariable(char *,int,bool *)'
1> c:\users\roar\documents\visual studio 2010\projects\iocpclient_ngx v0.3\PmdgSiocConnector.h(28): or 'int PmdgGetVariable(char *,int,short *)'
1> c:\users\roar\documents\visual studio 2010\projects\iocpclient_ngx v0.3\PmdgSiocConnector.h(29): or 'int PmdgGetVariable(char *,int,unsigned short *)'
1> c:\users\roar\documents\visual studio 2010\projects\iocpclient_ngx v0.3\PmdgSiocConnector.h(30): or 'int PmdgGetVariable(char *,int,int *)'
1> c:\users\roar\documents\visual studio 2010\projects\iocpclient_ngx v0.3\PmdgSiocConnector.h(31): or 'int PmdgGetVariable(char *,int,unsigned int *)'
1> c:\users\roar\documents\visual studio 2010\projects\iocpclient_ngx v0.3\PmdgSiocConnector.h(32): or 'int PmdgGetVariable(char *,int,float *)'
1> while trying to match the argument list '(const char [4], int, int)'
I am new to C++ and overloads. What am I doing wrong? What should/can I have as the 3rd argument?
rgs
There are two issues here.
"MCP" has type char const[4] which decays into char const*. This is not compatible with the first argument char*. Maybe you need to fix those function signatures to take char const* arguments?
If the functions are not yours and are correct (i.e., they actually need to change the first argument), then you need to pass an argument that is mutable:
char mcp[] = "MCP"; // now this properly decays to char*
int res = PmdgGetVariable(mcp, 0, 0); // beware of buffer overflow issues
If the function signatures are not correct because they don't change the first argument, despite taking a non-const parameter, you can resort to const_cast.
The other problem is that 0 can be converted to all those pointer types. There is no way for the compiler to decide which one of those functions to pick. You need to either be explicit about the type with a cast, or use a variable with the proper type.
PmdgGetVariable(mcp, 0, static_cast<int*>(0));
I find it strange that the function can be called with a null pointer and has all those overloads. Maybe it requires a non-null pointer?
int x = 0;
int res = PmdgGetVariable(mcp, 0, &x);
The problem is with the first parameter. Character literals ("MCP" in your example) are of type const char* and there is no overload that has const char* as its first argument.
I'd say it is because your call is ambiguous. Since you are passing a nullptr as your third parameter without type information, any of the overloads shown could potentially be correct.
To fix, try something like:
bool fParam = true;
int res = PmdgGetVariable("MCP", 0, &fParam );
All your overloads have a pointer as the third parameter & so, if you don't pass a pointer, the compiler will generate an error.
What are you doing wrong - don't know. What is this function supposed to do? Is it supposed to return a result into a caller var passed by reference? I'm guessing so because the third param. is names 'result', so:
bool myResult;
..
int res = PmdgGetVariable("MCP", 0, &myResult);
..or any of the other 5 overloaded result types.
Because when you write:
PmdgGetVariable("MCP", 0, 0);
Just looking at this line and knowing there are many possible such functions, how do you know if you're referring to the PmdgGetVariable with the third parameter bool*? short*? int*?. When you specify the literal '0', that literal could be referring to any of those types