Greetings. I'm working from Dohan Ibrahim's Advanced Microcontrollers book. My first program is exactly this:
void main()
{
unsigned int Sum, i;
TRISC=0
Sum=0;
For (i=1; i<=10; i++)
{
Sum = Sum + i;
}
PORTC=Sum;
}
When I build this, I get a Function Main Not Defined error. It's been decades since I wrote anything in C. I don't recall ever having to define the Main function. I am using the free limited edition of MikroC. Your help is greatly appreciated in advance.
Newbie Error Function Main Not Defined
you are missing a ; after trisc.
But this simple app has also revealed something I'd never thought about before. Even adding the ; gives and error on the 'For' it appears that MC does like the capital F, change to 'for' and it compiles ok.
I tried a 'While()' and that objects as well, not checked any other commands (yet).
But this simple app has also revealed something I'd never thought about before. Even adding the ; gives and error on the 'For' it appears that MC does like the capital F, change to 'for' and it compiles ok.
I tried a 'While()' and that objects as well, not checked any other commands (yet).
Thank you but error persists
Thanks very much. I'm embarrassed by my oversight....it's 3 AM when I did this. Unfortunately, I changed the code as follows and I still get the same error:
void main()
{
unsigned int Sum, i;
TRISC = 0;
Sum = 0;
for (i=1; i<=10; i++)
{
Sum = Sum + i;
}
PORTC = Sum;
}
Is this MikroC pretty picky about column positions perhaps ??
void main()
{
unsigned int Sum, i;
TRISC = 0;
Sum = 0;
for (i=1; i<=10; i++)
{
Sum = Sum + i;
}
PORTC = Sum;
}
Is this MikroC pretty picky about column positions perhaps ??
-
- Posts: 173
- Joined: 09 Apr 2008 12:56
For the record, you'll see that error if you try and build a C file without creating/saving a project file. That's why starting all over worked out for you. If you get that error again, just go to Save Project As, etc and it should work.
How do I know this? Cuz I had that same problem and it took me far longer to figure out the problem than it should have . . .
How do I know this? Cuz I had that same problem and it took me far longer to figure out the problem than it should have . . .
Thats probably due to ANSI Cs case sensitivitypwdixon wrote:you are missing a ; after trisc.
But this simple app has also revealed something I'd never thought about before. Even adding the ; gives and error on the 'For' it appears that MC does like the capital F, change to 'for' and it compiles ok.
I tried a 'While()' and that objects as well, not checked any other commands (yet).
Re: Newbie Error Function Main Not Defined
So I have the same error. Still Searching for this problem. I will write if I found. Thanks a lot
Re: Newbie Error Function Main Not Defined
I am also having the same problem FOR THE EXAMPLE MANCHESTER CODE given in help. I just copy and paste the code and compile! Error is "main function not defined" please help me i am in middle of a project
http://microcontrollerprojects00.blogspot.com/
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.
Re: Newbie Error Function Main Not Defined
Hi,
Most likely you didn't include the source file where you pasted your code into the project that you are trying to compile.
Please, use Project Manager and add the source file and it should compile OK.
Regards,
Filip.
Most likely you didn't include the source file where you pasted your code into the project that you are trying to compile.
Please, use Project Manager and add the source file and it should compile OK.
Regards,
Filip.