I am in a weird predicament where i have no control of libraries that am using. To explain further, I am using two libraries liba and libb. Libb needs liba to function. Now here comes the problem, liba not only contain the class but it also defines it and libb looks for that definition. Its all good when everything works but when its not, im out of luck.
liba.h
class myclassA{
// some code here
};
myclassA varA(0,2,1,3); //The parameters need to be changed
Of course i can edit liba.h locally, but that would mean if my code were to be compiled with another compute the modification would not persist and would have to edit its liba.h, every single time for every computer.
So is there some way to force redifine varA without throwing an error at compilation?
mycode looks like this:
#include <liba.h>
myvlassA varA(0,1,2,3); // Of course this throws a multiple definition error
#include <libb.h>
Is there a way around of basically deleting the old variable difinition with my new one?
CodePudding user response:
#include <liba.h>
myclassA myVarA(0,1,2,3);
#define varA myVarA
#include <libb.h>
CodePudding user response:
At one point I had to do something similar maybe you want something like
#include <stdio.h>
/* gcc lmao.c -Wl,--wrap=puts -o lmao */
int __real_puts(const char*);
int __wrap_puts(const char*a) {
__real_puts("u just got hacked\n");
__real_puts(a);
}
int main() {
/* gcc uses puts for this cool right*/
printf("main, calling thing\n");
}
this will print
u just got hacked
main, calling thing