0

I have a static library which contains object files, I want to wrap a function which is called in one object file and is defined in another object file, I am trying to use the method suggested in Override a function call in C using the gcc --wrap option.

Suppose I want to override a function getnamei(), I created a wrap.C file and defined __wrap__getnamei(), then compiled it to get an object file, then using the --wrap option I am able to override the function, but when I try to call the real function with __real__getnamei() in wrap.C, I get "error: '__real__getnamei() was not declared in this scope' ".

I am running on Windows 7, using MinGW

Community
  • 1
  • 1
Nithi89
  • 119
  • 2
  • 11

1 Answers1

0

I figured it out, in wrap.C we need to add a declaration of the function with extern "C" __real__getnamei(), then everything works fine!!

Nithi89
  • 119
  • 2
  • 11