Wrapper functions

Joined
Apr 14, 2020
Messages
5
Reaction score
0
Hey guys, I am trying to write a wrapper for this function:

Code:
BOOL8 GetOwnerNo(UCHAR* pItemNoStr, UINT16 maxLen)
{
  strncpy(reinterpret_cast<char*>(pItemNoStr), GetOwnerNoString(), maxLen - 1);

  pItemNoStr[maxLen - 1] = 0;

  return ValidData;
}

Here is the definition for the function:

Code:
extern BOOL8  GetOwnerNo( UCHAR* pItemNoStr, UINT16 maxLen );

So I believe a "wrapper" is just a function that basically points to another function, correct? On that note, after importing the header for the above function into my header file, I wrote this:

Code:
virtual BOOL8 GetOwnerNo(UCHAR* pItemNoStr, UINT16 maxLen);

and in the C++ file I created this definition:

Code:
  BOOL8 ConsoleManager::GetOwnerNo(UCHAR* pItemNoStr, UINT16 maxLen)
  {
    return GetOwnerNo(pItemNoStr, maxLen);
  }

which obviously gives me this warning:

Semantic Issue
175:3: warning: all paths through this function will call itself

Which means it's trying to call itself. Which I get, but am I just supposed to rename this "wrapper"? Is that how "wrappers" work?
 
Last edited:
Joined
Jul 3, 2021
Messages
37
Reaction score
2
So I believe a "wrapper" is just a function that basically points to another function, correct? On that note, after importing the header for the above function into my header file, I wrote this:

A wrapper is a function that calls another function (and/or does anything extra). Not one that points to another. Function pointers are something else.

C:
void someFunction(int x) {
  //some code.
}

void wrapper(int x, int y) {
  //your code.
  someFunction(x);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top