• AVR Freaks

Hot!Another question about " return type of 'main' is not 'int' "

Author
vra
Starting Member
  • Total Posts : 66
  • Reward points : 0
  • Joined: 2014/07/14 18:35:19
  • Location: 0
  • Status: offline
2019/07/15 18:12:38 (permalink)
0

Another question about " return type of 'main' is not 'int' "

Hi all, how are you?.
 
I'm just starting a project using a PIC24EP with XC16 compiler, when I add a main file by adding a new file feature of mplabx but the main pre-made file comes with this content:
 
void main(void) 
{
    XXXXX
    return;
}

 
When the project is compiled the compiler gives de warning return type of 'main' is not 'int', so I've read the following post:
 
https://www.microchip.com/forums/m419093.aspx
 
where they said that main must be declared as an int, then I modify the file like this:

int main(void) 
{
    XXXXX
    return 0;

 
and the warning doesn't appear anymore so, it is possible to modify the pre-made main file on mplabx file to make it appear in the right way?
#1

7 Replies Related Threads

    ric
    Super Member
    • Total Posts : 23185
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/15 18:23:15 (permalink)
    4 (1)
    WHICH template file are you using?
    Microchip Embedded, XC16 Compiler, mainXC16.c
    gives the correct blank file.
     
    "main.c" will be remembered from when you created a file using a different template.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    vra
    Starting Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/15 18:32:50 (permalink)
    0
    ric
    WHICH template file are you using?
    Microchip Embedded, XC16 Compiler, mainXC16.c
    gives the correct blank file.
     
    "main.c" will be remembered from when you created a file using a different template.
     


    Ok thanks, so what can I do to set the XC16 to put the correct template when a new file is created?
    #3
    ric
    Super Member
    • Total Posts : 23185
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/15 18:37:45 (permalink)
    4 (1)
    As I said, it remembers the last template you used.
    HOW are you adding files?
    If you are right-clicking on the "Source" item in the project tree, select "Other...", then navigate to what I said in the previous post. Next time you do it, "mainXC16.c" will appear at the top of the list.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    BobAGI
    Super Member
    • Total Posts : 1715
    • Reward points : 0
    • Joined: 2011/03/09 00:04:35
    • Location: Texas and Sweden
    • Status: offline
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/15 23:04:02 (permalink)
    0
    Why return from main() at all?
    It will effectively stop your application execution in the PIC and possibly reset the hardware.
    Normally you do not ever return from main() at all, it contains an eternal loop inside of which the application lives.

    --
    Bo B
    Sweden & Texas
     
    #5
    ric
    Super Member
    • Total Posts : 23185
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/15 23:13:43 (permalink)
    4 (2)
    Agree, it should never get to the return.
    I think the OP is just looking for a way to start new files that will have the correct main syntax.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    vra
    Starting Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/16 04:10:52 (permalink)
    0
    ric
    Agree, it should never get to the return.
    I think the OP is just looking for a way to start new files that will have the correct main syntax.
     


    Yes, thats it.
    #7
    vra
    Starting Member
    • Total Posts : 66
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Another question about " return type of 'main' is not 'int' " 2019/07/16 04:11:15 (permalink)
    0
    ric
    Agree, it should never get to the return.
    I think the OP is just looking for a way to start new files that will have the correct main syntax.
     


    Yes, thats it.
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5