简体   繁体   English

编译器不支持目标架构上的 64 位整数

[英]Compiler does not support 64-bit integers on target Architechture

I am new to MPLAB XC8 compiler and don't know why this error is happening as I did not use any number that is of 64 bit in my code.我是 MPLAB XC8 编译器的新手,不知道为什么会发生此错误,因为我没有在代码中使用任何 64 位数字。

Code is as follow代码如下

#include <pic16f877a.h>
#pragma config FOSC = EXTRC 
#pragma config WDTE = ON 
#pragma config PWRTE = OFF 
#pragma config BOREN = ON 
#pragma config LVP = ON 
#pragma config CPD = OFF 
#pragma config WRT = OFF 
#pragma config CP = OFF 
#define _XTAL_FREQ 8000000
#include <xc.h>
void main(void) 
{
    TRISB=0x00;
    while(1)
    {
    PORTB = 0xFF;
    __delay_ms(500);
    PORTB = 0x00 ;
    __delay_ms(500);
    }
return;
}

The XC8 user's guide documents the __delay_ms macro, and explains that: XC8 用户指南记录了__delay_ms宏,并解释说:

An error will result if these macros are used without defining the oscillator frequency symbol, the delay period requested is too large...如果在未定义振荡器频率符号的情况下使用这些宏,将导致错误,请求的延迟周期太大...

Try using a much smaller delay, like 1 ms.尝试使用更小的延迟,例如 1 毫秒。 You can wrap the delay in a loop that iterates 500 times if you need to.如果需要,您可以将延迟包装在一个迭代 500 次的循环中。 The compiler likely encountered some numbers that could not fit in a 32-bit integer when it tried to turn your long delays into machine code, and it's unfortunate that it didn't give a better error message.编译器在尝试将长时间延迟转换为机器代码时可能会遇到一些无法放入 32 位整数的数字,不幸的是它没有给出更好的错误消息。

Also, if I am right about this, it should serve as lesson in simplification.另外,如果我对此是正确的,它应该作为简化的教训。 You could have solved this yourself by simplifying the program down to the point where there is only one line of code in main and it is calling __delay_ms(500) .您可以通过将程序简化到main中只有一行代码并且它正在调用__delay_ms(500)来解决这个问题。 Then, to simplify further, you would have tried reducing the delay and noticed that the problem goes away.然后,为了进一步简化,您会尝试减少延迟并注意到问题消失了。 You would have figured it out yourself instead of having to wait 2 days for a StackOverflow answer.您会自己弄清楚,而不必等待 2 天才能得到 StackOverflow 的答案。 See How to create a Minimal, Reproducible Example .请参阅如何创建最小的、可重现的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM