问题
I'm using Microchip's XC8 compiler. They want me to #include <xc.h>
instead of including a chip-specific header. However, when I add this code on the first line of my code, I'm getting the error:
Error [224] C:\...\main.c; 1.4 illegal "#" directive
When I place a line feed before the directive, I don't get the error. Why is this?
My full code:
#include <xc.h>
#pragma config OSC =INTIO67, WDT = OFF, LVP = OFF, PBADEN = OFF
void main() {
while (1);
}
With the line feed, the code looks just the same, but with a blank line on top.
回答1:
One thing that may cause this is corruption or other characters at the start of the file that aren't visible within your text editor. Depending on the editor it may well be the byte order mark that is used with Unicode files. I suggest taking a look at the first few lines of the file with a hex editor so that you can locate any characters that may be causing the problem.
来源:https://stackoverflow.com/questions/16262691/xc8-error-224-illegal-directive-first-line