View previous topic :: View next topic |
Author |
Message |
rwjzownts
Joined: 19 Jul 2008 Posts: 16
|
stdlib trouble |
Posted: Sat Jul 19, 2008 3:50 pm |
|
|
Hi. I'm getting a strange error regarding #include stdlib.h. The program suddenly can't find that file. When I compile this code:
Code: | #include <18F2620.h>
#FUSES HS
#FUSES NOWDT
#FUSES NOPROTECT
#use delay(clock=20,000,000)
#use rs232 (baud = 9600, parity = N, xmit = PIN_C6, rcv = PIN_C7, bits = 8, force_sw, invert)
#define KEYHIT_DELAY 500
#define RAND_MAX 1000
#include < STDLIB.H >
int16 delays;
void main()
{
while(true){
delays = RAND();
output_high (PIN_C4);
//delay_ms(1000);
delay_ms(delays);
output_low (PIN_C4);
//delay_ms(1000);
delay_ms(delays);
}
}
|
I get these errors:
*** Error 18 "stdlibtest.c" Line 9(10,22): File can not be opened
Not in "C:\Program Files\PICC\devices\STDLIB.H"
Not in "C:\Program Files\PICC\drivers\STDLIB.H"
Not in local "C:\Documents and Settings\Administrator\Desktop\STDLIB.H"
***Error 12 "stdlibtest.c" Line 16(13,17): Undefined identifier RAND
2 Errors, 0 Warnings.
This was working fine, and then stopped for no reason that I can discern. STDLIB.H is in the drivers folder. I have also tried to moving it to the devices folder. Anyone know what the problem might be?
Thanks!
Richard |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jul 19, 2008 3:56 pm |
|
|
You have inserted some spaces in one of the lines in your program. You
have never seen this done in any example program. Remove those
spaces and the errors will go away.
The basic rule is, don't arbitrarily change things from the way you've
seen it done in example files. Try to keep it the same way they do it. |
|
|
rwjzownts
Joined: 19 Jul 2008 Posts: 16
|
Thanks! |
Posted: Sat Jul 19, 2008 4:01 pm |
|
|
That did it. Don't know how those spaces got there. I'll pay attention to those in the future. |
|
|
|