This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

8051

I run the following program in keil software....it shows printf ANSI-style prototype error....
please give a clue for correcting the error...

#include "Main.h"
#include "show.h"
#include "PRINTF51.c"
void sho_inti(void)
{ int (*fnptr)();
fnptr=show;
printf("Address of function:%u",&show);
(*fnptr)();
} void show(void)
{ printf("\n function called using pointer");
}

  • "I run the following program in keil software"

    That is not a program - that is just a snippet of source code.

    You didn't even bother to follow the instructions on how to post source code: www.danlhenry.com/.../keil_code.png

    "it shows printf ANSI-style prototype error"

    So fix the error in your ANSI-style prototype!

    You haven't included the standard header file that would give the correct prototype for printf, so presumably it must be in one of those other files that you've #included?

    As we don't have access to those files, how do you expect us to be able to comment on them?

    #include "PRINTF51.c"
    

    Why are you #including a .c file??

  • There are serious issues with using function pointers in Keil C51!

    You need to carefully study the documentation and ensure that you really understand the issues before continuing with this...

    Just put "Function Pointer" into the 'Search' box, and see what you get...

  • If your function pointer should take zero parameters then you should have specified "void" in the parameter list.

    But why are you playing with function pointers?