鱼C论坛

 找回密码
 立即注册
查看: 500|回复: 1

[已解决]我这里有什么问题吗

[复制链接]
发表于 2023-3-1 21:20:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <REGX52.H>
#include "Timer0.h"
#include "Key.h"
#include "Delay.h"
#include "Nixie.h"

unsigned char KeyNum;
unsigned char Temp;

void main ()
{
   Timer0_Init();

                while (1)
                {
                        KeyNum=Key();
    }

}

void Timer0_Routine() interrupt 1
{
        static unsigned int T0Count1,T0Count2;
        void Key_Loop(void);
        TL0 = 0x66;               
        TH0 = 0xFC;               
        T0Count1++;
        if(T0Count1>=20)
        {
                T0Count1=0;
          Key_Loop();
        }
        T0Count2++;
        if(T0Count2>=2)
        {
                T0Count2=0;
                Nixie_Loop();
        }

}

Build target 'Target 1'
compiling main.c...
main.c(7): error C132: 'KeyNum': not in formal parameter list
main.c(8): error C132: 'Temp': not in formal parameter list
main.c(11): error C132: 'main': not in formal parameter list
main.c(11): error C141: syntax error near '{'
main.c(14): error C132: 'Timer0_Init': not in formal parameter list
main.c(14): error C141: syntax error near 'while'
main.c(16): error C244: 'KeyNum': can't initialize, bad type or class
main.c(16): error C132: 'KeyNum': not in formal parameter list
main.c(17): error C141: syntax error near '}'
Target not created.
Build Time Elapsed:  00:00:00
最佳答案
2023-4-30 10:05:57
这段代码中有多处错误:

缺少头文件,应该添加 #include <INTRINS.H> 头文件,否则会出现 "error C141: syntax error near '{'"的编译错误。

函数声明放在中括号外面,应该将其放在函数内部。

在main()函数中,调用了 Key() 函数,但是未定义此函数,需要确认是否存在此函数并正确包含相关的头文件。

定义变量时出现语法错误,需要删除初始化语句"=Key()",定义为 unsigned char KeyNum; unsigned char Temp;

Timer0_Init()函数未在此文件中声明或定义,需要检查是否正确包含相关的头文件。

函数结束符“}”要写在main函数后面,而不是Timer0_Routine()中。

以下是修改后的代码:

  1. #include <REGX52.H>
  2. #include <INTRINS.H>
  3. #include "Timer0.h"
  4. #include "Key.h"
  5. #include "Delay.h"
  6. #include "Nixie.h"

  7. unsigned char KeyNum;
  8. unsigned char Temp;

  9. void main()
  10. {
  11. Timer0_Init();
  12. while (1)
  13. {
  14. KeyNum = Key();
  15. }
  16. }

  17. void Timer0_Routine() interrupt 1
  18. {
  19. static unsigned int T0Count1, T0Count2;
  20. TL0 = 0x66;
  21. TH0 = 0xFC;
  22. T0Count1++;
  23. if (T0Count1 >= 20)
  24. {
  25. T0Count1 = 0;
  26. Key_Loop();
  27. }
  28. T0Count2++;
  29. if (T0Count2 >= 2)
  30. {
  31. T0Count2 = 0;
  32. Nixie_Loop();
  33. }
  34. }

  35. void Key_Loop(void)
  36. {
  37. // TODO: 此函数的具体实现
  38. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-4-30 10:05:57 | 显示全部楼层    本楼为最佳答案   
这段代码中有多处错误:

缺少头文件,应该添加 #include <INTRINS.H> 头文件,否则会出现 "error C141: syntax error near '{'"的编译错误。

函数声明放在中括号外面,应该将其放在函数内部。

在main()函数中,调用了 Key() 函数,但是未定义此函数,需要确认是否存在此函数并正确包含相关的头文件。

定义变量时出现语法错误,需要删除初始化语句"=Key()",定义为 unsigned char KeyNum; unsigned char Temp;

Timer0_Init()函数未在此文件中声明或定义,需要检查是否正确包含相关的头文件。

函数结束符“}”要写在main函数后面,而不是Timer0_Routine()中。

以下是修改后的代码:

  1. #include <REGX52.H>
  2. #include <INTRINS.H>
  3. #include "Timer0.h"
  4. #include "Key.h"
  5. #include "Delay.h"
  6. #include "Nixie.h"

  7. unsigned char KeyNum;
  8. unsigned char Temp;

  9. void main()
  10. {
  11. Timer0_Init();
  12. while (1)
  13. {
  14. KeyNum = Key();
  15. }
  16. }

  17. void Timer0_Routine() interrupt 1
  18. {
  19. static unsigned int T0Count1, T0Count2;
  20. TL0 = 0x66;
  21. TH0 = 0xFC;
  22. T0Count1++;
  23. if (T0Count1 >= 20)
  24. {
  25. T0Count1 = 0;
  26. Key_Loop();
  27. }
  28. T0Count2++;
  29. if (T0Count2 >= 2)
  30. {
  31. T0Count2 = 0;
  32. Nixie_Loop();
  33. }
  34. }

  35. void Key_Loop(void)
  36. {
  37. // TODO: 此函数的具体实现
  38. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-11 04:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表