寄存器的XC8冲突声明(例如TRIS,SSP1CON1,......)

时间:2017-01-30 18:56:43

标签: c pic microchip xc8

我是新来的。我正在使用Microchip的XC8编译器和PIC18F25K22。 当我构建代码时,我收到错误

>>> "ABChi hi".count("hi")
2
>>> 

如果我注释掉这个代码行,我收到下一个寄存器命令的错误(在我的情况下:SSP1CON1) - 我尝试了包括xc.h 和htc.h但也有同样的错误。

我在stackoverflow中发现了一个类似的问题,但问题是通过将这些命令放在一个函数中来解决的,但是我的函数在函数中。

这是我的代码:

xc8.exe --pass1 --errformat="Error at file %%f line %%l column %%c: (%%n) %%s" --warnformat="Warning at file %%f line %%l column %%c: (%%n) %%s" --msgformat="Message at file %%f line %%l column %%c: (%%n) %%s" -G --chip=18F25K22  -O"main.p1" "../main.c"
Microchip MPLAB XC8 C Compiler (Free Mode) V1.37
Build date: Mar 10 2016
Part Support Version: 1.37
Copyright (C) 2016 Microchip Technology Inc.
License type: Node Configuration

Warning at file  line  column : (1273) Omniscient Code Generation not available in Free mode
Error at file ../i2clcd.c line 11 column 8: (195) expression syntax
Error at file ../i2clcd.c line 11 column 8: (312) ";" expected
Error at file ../i2clcd.c line 11 column 12: (285) no identifier in declaration
Error at file ../i2clcd.c line 11 column 12: (314) ";" expected
Error at file ../i2clcd.c line 14 column 10: (195) expression syntax
Error at file ../i2clcd.c line 14 column 10: (312) ";" expected
Error at file ../i2clcd.c line 14 column 14: (285) no identifier in declaration
Error at file ../i2clcd.c line 14 column 14: (314) ";" expected
Warning at file ../i2clcd.c line 23 column 1: (361) function declared implicit int
Error at file ../i2clcd.c line 51 column 11: (195) expression syntax
Error at file ../i2clcd.c line 51 column 11: (312) ";" expected
Error at file ../i2clcd.c line 51 column 15: (285) no identifier in declaration
Error at file ../i2clcd.c line 51 column 15: (314) ";" expected
Error at file ../i2clcd.c line 84 column 1: (192) undefined identifier "lcddata"
Error at file ../i2c.c line 10 column 1: (1098) conflicting declarations for variable "I2C_INIT" (../i2c.c:9)
(908) exit status = 1
make: *** [main.p1] Error 1

Error code 2

1 个答案:

答案 0 :(得分:2)

所有注册声明(SSP1CON1TRISCbits等都在xc.h中声明(并且它的嵌套包含)。您的问题可能是i2c.h包含引用了xc.h

中显示的定义

尝试撤消您的包含的顺序,以便在您自己(或第三方)包含之前将系统包含在内。

一般情况下,您应始终将所有系统包含(即文件用<>指定的那些)放在您自己的(包含&#34;&#34;)之后。