I know this is probably something obvious but it is not working so..
I am using gcc
I can not figure out to get a function ptr, without the function being in the same source file
this is my code:(not compiling)
Code: Select all
inline void InstallOp(unsigned char num,void *func){
Opcodes[num]=func;
}
void UninstallOp(unsigned char num){ //actually just sets the opcode to unknown
Opcodes[num]=unknown();
}
//void unknown();
void InitOpcodes(){
unsigned int i;
Opcodes=malloc(0xFF*sizeof(void *)); //trying to get ready for 64bit...lol
for(i=0;i<=0xFF;i++){
//HERE IS ERROR #1
InstallOp(i,unknown); //set all opcodes to unknown..
}
//HERE IS ERROR #2
InstallOp(0xF4,&hlt());
}
in error #1 it says that unknown is undefined even though if I try to define it as extern or a function it will throw an error of conflicting types
in error #2
I try getting the address of the function by a non-standard way(works on some compilers) but in gcc it treats it like trying to & a void (blank datatype..) and if I try removing the & then it trys running the function hlt() so that it can get the return value
so exactly how do I get the ptr to a function!?(without using some ridicoulous thing like using asm offset or just putting all my functions together in 1 source file)
EDIT:
ok dunno why but gcc doesn't like for function declarations to be done in source files, everything works if I put "void unknown();" in my global header file... very wierd problem