- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当函数类型从 int 更改为 void 时,出现冲突声明错误。下面的代码给出了错误“TimerSetup.c:4: error: (1098)变量“_Timer1Init”的冲突声明”。但如果在 TimerSetup.h 和 TimerSetup.c 文件中将 Timer1Init 的函数类型更改为 int,该错误就会消失。任何想法!为什么?
TimerSetup.h
// TimerSetup.h
#ifndef XC_HEADER_TEMPLATE_H
#define XC_HEADER_TEMPLATE_H
#include <xc.h> // include processor files - each processor file is guarded.
#include <stdint.h>
void Timer1Init(); //<-----Error vanish when type changed to int
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// TODO If C++ is being used, regular C code needs function names to have C
// linkage so the functions can be used by the c code.
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* XC_HEADER_TEMPLATE_H */
TimerSetup.c
#include <xc.h>
#include "TimerSetup.h"
void Timer1Init() //<-----Error vanish when type changed to int
{
PIE1bits.TMR1IE=1;
PIR1bits.TMR1IF=0;
}
Wifi.c
#include <xc.h>
#include "Wifi.h"
void eUart1Init()
{
TRISB=0;
TRISC6=0; /* Make Tx pin as output*/
TRISC7=1; /* Make Rx pin as input*/
TXSTA1 = 0;
TXSTA1bits.BRGH = 1; // high baud rate
BAUDCON1bits.BRG16 = 0;
BAUDCON1 = 0;
PMD0 = 0;
TXSTA1bits.TX9 = 0;
TXSTA1bits.TXEN = 1;
TXSTA1bits.SENDB = 0;
TXSTA1bits.BRGH = 1;
RCSTA1bits.SPEN = 1;
RCSTA1bits.RX9 = 0;
RCSTA1bits.CREN = 1;
RCSTA2bits.CREN = 1;
SPBRG1 = 51;
IPR1bits.TX1IP = 0; // Interrupt priority bit
PIR1bits.TX1IF = 0;
PIE1bits.TX1IE = 1;
IPR1bits.RC1IP = 0; // Interrupt priority bit /////////
PIR1bits.RC1IF = 0;
PIE1bits.RC1IE = 1;
}
void eUart2Init()
{
TRISB6=0; /* Make Tx2 pin as output*/
TRISB7=1; /* Make Rx2 pin as input*/
TXSTA2 = 0;
TXSTA2bits.BRGH = 1; // high baud rate
BAUDCON2bits.BRG16 = 0;
BAUDCON2 = 0;
//PMD0 = 0;
TXSTA2bits.TX9 = 0;
TXSTA2bits.TXEN = 1;
TXSTA2bits.SENDB = 0;
TXSTA2bits.BRGH = 1;
RCSTA2bits.SPEN = 1;
RCSTA2bits.RX9 = 0;
RCSTA2bits.CREN = 1;
SPBRG2 = 51;
IPR3bits.TX2IP = 0; // Interrupt priority bit
PIR3bits.TX2IF = 0;
PIE3bits.TX2IE = 1;
IPR3bits.RC2IP = 0; // Interrupt priority bit
PIR3bits.RC2IF = 0;
PIE3bits.RC2IE = 1;
}
// EUART1 Put String Function Defines Here
void eUart1Puts(const char *s)
{
while(*s)
eUart1PutByte(*s++);
}
void eUart2Puts(const char *s)
{
while(*s)
eUart2PutByte(*s++);
}
void eUart1PutByte(unsigned char byte)
{
while((PIR1bits.TX1IF != 1) && (TXSTA1bits.TXEN1 != 0)) // set when register is empty
continue;
PIE1bits.TX1IE = 1;
TXREG1 = byte;
}
void eUart2PutByte(unsigned char byte)
{
while((PIR3bits.TX2IF != 1) && (TXSTA2bits.TXEN2 != 0)) // set when register is empty
continue;
PIE1bits.TX1IE = 1;
TXREG2 = byte;
}
void WifiAT(char *command)
{
eUart1Puts(command);
//__delay_ms(wifi_wait);
while (eusart_rx_buffer_rd != eusart_rx_buffer_wr)
{ // While there's data in the buffer
eUart2PutByte(eusart_rx_buffer[eusart_rx_buffer_rd++]); // Do something with it
if (eusart_rx_buffer_rd >= EUSART_BUFFER_SIZE) // Increase read pointer
{
eusart_rx_buffer_rd = 0;
}
}
}
__interrupt() void ISR(void) //<----------------------- To here
{
if((PIR3bits.TX2IF == 1) && (PIE3bits.TX2IE == 1)) //Debug Terminal Tx
{
PIR3bits.TX2IF = 0;
PIE3bits.TX2IE = 0;
}
if((PIR3bits.RC2IF != 0) && (PIE3bits.RC2IE != 0)) //Debug Terminal Rx
{
PIR3bits.RC2IF = 0;
rc2_data = RCREG2;
}
if((PIR1bits.TX1IF != 0) && (PIE1bits.TX1IE != 0))
{
PIR1bits.TX1IF = 0;
PIE1bits.TX1IE = 0;
}
if((PIR1bits.RC1IF != 0) && (PIE1bits.RC1IE != 0))
{
// rc_data = RCREG1;
// eUart2PutByte(rc_data);
eusart_rx_buffer[eusart_rx_buffer_wr++] = RCREG1; // Store the received data
if (eusart_rx_buffer_wr >= EUSART_BUFFER_SIZE) // Increment write pointer
{
eusart_rx_buffer_wr = 0;
}
PIR1bits.RC1IF = 0;
}
// if((PIR1bits.TMR1IF != 0) && (PIE1bits.TMR1IE != 0))
// {
// int flag = 0;
// TMR1=0xF856;
// if(flag >= 1000)
// {
// PORTCbits.RC1 = ~(PORTCbits.RC1);
// PIR1bits.TMR1IF=0; /* Make Timer1 Overflow Flag to '0' */
// }
// }
}
TokMain.c
#include <xc.h>
#include "Wifi.h"
void eUart1Init()
{
TRISB=0;
TRISC6=0; /* Make Tx pin as output*/
TRISC7=1; /* Make Rx pin as input*/
TXSTA1 = 0;
TXSTA1bits.BRGH = 1; // high baud rate
BAUDCON1bits.BRG16 = 0;
BAUDCON1 = 0;
PMD0 = 0;
TXSTA1bits.TX9 = 0;
TXSTA1bits.TXEN = 1;
TXSTA1bits.SENDB = 0;
TXSTA1bits.BRGH = 1;
RCSTA1bits.SPEN = 1;
RCSTA1bits.RX9 = 0;
RCSTA1bits.CREN = 1;
RCSTA2bits.CREN = 1;
SPBRG1 = 51;
IPR1bits.TX1IP = 0; // Interrupt priority bit
PIR1bits.TX1IF = 0;
PIE1bits.TX1IE = 1;
IPR1bits.RC1IP = 0; // Interrupt priority bit /////////
PIR1bits.RC1IF = 0;
PIE1bits.RC1IE = 1;
}
void eUart2Init()
{
TRISB6=0; /* Make Tx2 pin as output*/
TRISB7=1; /* Make Rx2 pin as input*/
TXSTA2 = 0;
TXSTA2bits.BRGH = 1; // high baud rate
BAUDCON2bits.BRG16 = 0;
BAUDCON2 = 0;
//PMD0 = 0;
TXSTA2bits.TX9 = 0;
TXSTA2bits.TXEN = 1;
TXSTA2bits.SENDB = 0;
TXSTA2bits.BRGH = 1;
RCSTA2bits.SPEN = 1;
RCSTA2bits.RX9 = 0;
RCSTA2bits.CREN = 1;
SPBRG2 = 51;
IPR3bits.TX2IP = 0; // Interrupt priority bit
PIR3bits.TX2IF = 0;
PIE3bits.TX2IE = 1;
IPR3bits.RC2IP = 0; // Interrupt priority bit
PIR3bits.RC2IF = 0;
PIE3bits.RC2IE = 1;
}
// EUART1 Put String Function Defines Here
void eUart1Puts(const char *s)
{
while(*s)
eUart1PutByte(*s++);
}
void eUart2Puts(const char *s)
{
while(*s)
eUart2PutByte(*s++);
}
void eUart1PutByte(unsigned char byte)
{
while((PIR1bits.TX1IF != 1) && (TXSTA1bits.TXEN1 != 0)) // set when register is empty
continue;
PIE1bits.TX1IE = 1;
TXREG1 = byte;
}
void eUart2PutByte(unsigned char byte)
{
while((PIR3bits.TX2IF != 1) && (TXSTA2bits.TXEN2 != 0)) // set when register is empty
continue;
PIE1bits.TX1IE = 1;
TXREG2 = byte;
}
void WifiAT(char *command)
{
eUart1Puts(command);
//__delay_ms(wifi_wait);
while (eusart_rx_buffer_rd != eusart_rx_buffer_wr)
{ // While there's data in the buffer
eUart2PutByte(eusart_rx_buffer[eusart_rx_buffer_rd++]); // Do something with it
if (eusart_rx_buffer_rd >= EUSART_BUFFER_SIZE) // Increase read pointer
{
eusart_rx_buffer_rd = 0;
}
}
}
__interrupt() void ISR(void) //<----------------------- To here
{
if((PIR3bits.TX2IF == 1) && (PIE3bits.TX2IE == 1)) //Debug Terminal Tx
{
PIR3bits.TX2IF = 0;
PIE3bits.TX2IE = 0;
}
if((PIR3bits.RC2IF != 0) && (PIE3bits.RC2IE != 0)) //Debug Terminal Rx
{
PIR3bits.RC2IF = 0;
rc2_data = RCREG2;
}
if((PIR1bits.TX1IF != 0) && (PIE1bits.TX1IE != 0))
{
PIR1bits.TX1IF = 0;
PIE1bits.TX1IE = 0;
}
if((PIR1bits.RC1IF != 0) && (PIE1bits.RC1IE != 0))
{
// rc_data = RCREG1;
// eUart2PutByte(rc_data);
eusart_rx_buffer[eusart_rx_buffer_wr++] = RCREG1; // Store the received data
if (eusart_rx_buffer_wr >= EUSART_BUFFER_SIZE) // Increment write pointer
{
eusart_rx_buffer_wr = 0;
}
PIR1bits.RC1IF = 0;
}
// if((PIR1bits.TMR1IF != 0) && (PIE1bits.TMR1IE != 0))
// {
// int flag = 0;
// TMR1=0xF856;
// if(flag >= 1000)
// {
// PORTCbits.RC1 = ~(PORTCbits.RC1);
// PIR1bits.TMR1IF=0; /* Make Timer1 Overflow Flag to '0' */
// }
// }
}
Wifi.h
// This is a guard condition so that contents of this file are not included
// more than once.
#ifndef XC_HEADER_TEMPLATE_H
#define XC_HEADER_TEMPLATE_H
#include <xc.h> // include processor files - each processor file is guarded.
#include <stdint.h>
#define _XTAL_FREQ 8000000UL
#define EUSART_BUFFER_SIZE 1024
char rc2_data;
char rc_data;
char eusart_rx_buffer[EUSART_BUFFER_SIZE]; // the actual buffer, now 2048 bytes long
uint16_t eusart_rx_buffer_rd = 0; // the current read position
uint16_t eusart_rx_buffer_wr = 0; // the current write position
void eUart1Init();
void eUart2Init();
void eUart1PutByte(unsigned char byte);
void eUart2PutByte(unsigned char byte);
void eUart1Puts(const char *s);
void eUart2Puts(const char *s);
void WifiAT(char *command);
// TODO Insert declarations or function prototypes (right here) to leverage
// live documentation
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// TODO If C++ is being used, regular C code needs function names to have C
// linkage so the functions can be used by the c code.
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* XC_HEADER_TEMPLATE_H */
完整错误消息:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'E:/pk/TokenOverWiFi.X'
make -f nbproject/Makefile-default.mk dist/default/production/TokenOverWiFi.X.production.hex
make[2]: Entering directory 'E:/pk/TokenOverWiFi.X'
"C:\Program Files (x86)\Microchip\xc8\v1.44\bin\xc8.exe" --pass1 --chip=18F25K80 -Q -G --double=24 --float=24 --emi=wordwrite --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/TokMain.p1 TokMain.c
TokMain.c:81: warning: (361) function declared implicit int
"C:\Program Files (x86)\Microchip\xc8\v1.44\bin\xc8.exe" --chip=18F25K80 -G -mdist/default/production/TokenOverWiFi.X.production.map -DXPRJ_default=default --double=24 --float=24 --emi=wordwrite --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" --memorysummary dist/default/production/memoryfile.xml -odist/default/production/TokenOverWiFi.X.production.elf build/default/production/TokMain.p1 build/default/production/Wifi.p1 build/default/production/TimerSetup.p1
Microchip MPLAB XC8 C Compiler (Free Mode) V1.44
Build date: Sep 13 2017
Part Support Version: 1.44
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration
:: warning: (1273) Omniscient Code Generation not available in Free mode
TimerSetup.c:4: error: (1098) conflicting declarations for variable "_Timer1Init" (TokMain.c:81)
make[2]: *** [dist/default/production/TokenOverWiFi.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
(908) exit status = 1
nbproject/Makefile-default.mk:163: recipe for target 'dist/default/production/TokenOverWiFi.X.production.hex' failed
make[2]: Leaving directory 'E:/pk/TokenOverWiFi.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'E:/pk/TokenOverWiFi.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 805ms)
编辑
当我注释掉其他头文件时,代码编译成功。如何??
最佳答案
问题在于您在每个头文件中对头保护使用相同的名称,因此您阻止了编译器查看大部分代码。
#ifndef XC_HEADER_TEMPLATE_H
#define XC_HEADER_TEMPLATE_H
这应该类似于 #ifndef WIFI_H
、#ifndef TIMER_SETUP_H
等。为每个头文件选择一个唯一的名称。
关于c - "error: (1098) conflicting declarations"当函数类型改变时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58075580/
我正在尝试编写一个相当多态的库。我遇到了一种更容易表现出来却很难说出来的情况。它看起来有点像这样: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE
谁能解释一下这个表达式是如何工作的? type = type || 'any'; 这是否意味着如果类型未定义则使用“任意”? 最佳答案 如果 type 为“falsy”(即 false,或 undef
我有一个界面,在IAnimal.fs中, namespace Kingdom type IAnimal = abstract member Eat : Food -> unit 以及另一个成功
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: What is the difference between (type)value and type(va
在 C# 中,default(Nullable) 之间有区别吗? (或 default(long?) )和 default(long) ? Long只是一个例子,它可以是任何其他struct类型。 最
假设我有一个案例类: case class Foo(num: Int, str: String, bool: Boolean) 现在我还有一个简单的包装器: sealed trait Wrapper[
这个问题在这里已经有了答案: Create C# delegate type with ref parameter at runtime (1 个回答) 关闭 2 年前。 为了即时创建委托(dele
我正在尝试获取图像的 dct。一开始我遇到了错误 The function/feature is not implemented (Odd-size DCT's are not implemented
我正在尝试使用 AFNetworking 的 AFPropertyListRequestOperation,但是当我尝试下载它时,出现错误 预期的内容类型{( “应用程序/x-plist” )}, 得
我在下面收到错误。我知道这段代码的意思,但我不知道界面应该是什么样子: Element implicitly has an 'any' type because index expression is
我尝试将 SignalType 从 ReactiveCocoa 扩展为自定义 ErrorType,代码如下所示 enum MyError: ErrorType { // .. cases }
我无法在任何其他问题中找到答案。假设我有一个抽象父类(super class) Abstract0,它有两个子类 Concrete1 和 Concrete1。我希望能够在 Abstract0 中定义类
我想知道为什么这个索引没有用在 RANGE 类型中,而是用在 INDEX 中: 索引: CREATE INDEX myindex ON orders(order_date); 查询: EXPLAIN
我正在使用 RxJava,现在我尝试通过提供 lambda 来订阅可观察对象: observableProvider.stringForKey(CURRENT_DELETED_ID) .sub
我已经尝试了几乎所有解决问题的方法,其中包括。为 提供类型使用app.use(express.static('public'))还有更多,但我似乎无法为此找到解决方案。 index.js : imp
以下哪个 CSS 选择器更快? input[type="submit"] { /* styles */ } 或 [type="submit"] { /* styles */ } 只是好
我不知道这个设置有什么问题,我在 IDEA 中获得了所有注释(@Controller、@Repository、@Service),它在行号左侧显示 bean,然后转到该 bean。 这是错误: 14-
我听从了建议 registering java function as a callback in C function并且可以使用“简单”类型(例如整数和字符串)进行回调,例如: jstring j
有一些 java 类,加载到 Oracle 数据库(版本 11g)和 pl/sql 函数包装器: create or replace function getDataFromJava( in_uLis
我已经从 David Walsh 的 css 动画回调中获取代码并将其修改为 TypeScript。但是,我收到一个错误,我不知道为什么: interface IBrowserPrefix { [
我是一名优秀的程序员,十分优秀!