Function Prototype Error in C

Discussion in 'Programmer's Corner' started by jegues, Jan 23, 2012.

  1. jegues

    Thread Starter Well-Known Member

    Sep 13, 2010
    735
    43
    I can't figure out why I'm getting function prototype errors as indicated in the figure when I try to compile.

    I've included my FunctionPrototypes.h in main, so it should find the prototype for main there as indicated in the figure.

    Why am I getting errors?
     
  2. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    I may be wrong here but I don't think you need to provide a prototype for main() as it's not really called by you it's just used to indicate the entry point of your program...

    Also I believe printf() for htc is declared to return an unsigned char unless you're using a PIC18, but seeing as how you haven't included the appropriate header the compiler is assuming that it returns an int and is just letting you know this. Including <stdio.h> should sort that warning out... The same goes for the Abs() funtion you're using, you need the include the header that contains the declaration, possibly <stdlib.h> though don't quote me on that.
     
    Last edited: Jan 24, 2012
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Repost your code an error Messages in a readable format. This is probably schoolwork. But even so I do not mind give some help or point you in the correct direction. And I guess this will be the same for most of members at AAC. You do not have use "smart" tricks trying to cover up that you ask for help. Like hiding your code in a blurry bitmap:mad:
     
  4. codehead

    Member

    Nov 28, 2011
    56
    11
    You don't need to declare main. It returns int. Compiler's mightily pissed ;)

    Lose the prototype, and start your program with,

    int main(void)...
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The using HI-Tech C The putch() function is empty. It should be customised to suit the project at hand. Often printf() prints to a USART, but it could define stdout as being an LCD or SPI. Code to initialize the intended destination must be executed before printf() can be called. If you do not have defined your own putch() you will get an error. This may be the source of your second error
     
  6. codehead

    Member

    Nov 28, 2011
    56
    11
    Your browser is resizing it to your window—click on it, most probably, to see it full-size.
     
  7. stahta01

    Member

    Jun 9, 2011
    133
    21
    Is not the first error because he has "Abs" instead of "abs"?

    Tim S.
     
  8. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    to be fair that's the error you would get (and I did get when I tried it:)), the two you can see in his attached pic are just warnings, they wouldn't halt compilation.
     
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Please post your code and error messages using the forum's code tags.

    code and /code but with brackets around each keyword []
     
Loading...