3758 views|6 replies

76

Posts

0

Resources
The OP
 

Problems using MPLAB XIDE [Copy link]

In MPLAB X IDE, can't a switch statement use a variable after a case? switch(Displacement[5]) { case Displacement[0]: Run_Section = 0; // break in acceleration section; Like above, the error is as follows Interrupt.c:297:9: error: case label does not reduce to an integer constant case Displacement[0]: I remember that some compilers can use this, does MPLAB not allow this?
This post is from Microchip MCU

Latest reply

Is there any professional book for learning mplab x ide that explains x ide more comprehensively?  Details Published on 2018-12-23 14:23
 

4005

Posts

0

Resources
2
 
It is not OK to follow a case with a variable, but it is OK to follow a logical condition.
This post is from Microchip MCU
 
 
 

1w

Posts

25

Resources
3
 
I have the impression that case cannot use variables and can only be judged by integers, so that the compiler can generate efficient optimized code. Otherwise, it is better to use if-else directly.
This post is from Microchip MCU
 
 
 

76

Posts

0

Resources
4
 
But you can do this in Keil
This post is from Microchip MCU

Comments

Upload keil diagram and code.  Details Published on 2018-11-21 09:34
 
 
 

7422

Posts

2

Resources
5
 
asdmaill posted on 2018-11-21 09:13 But you can do this in Keil
Here are the Keil pictures and codes.
This post is from Microchip MCU
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

6

Posts

0

Resources
6
 
Use constant
This post is from Microchip MCU
 
 
 

1

Posts

0

Resources
7
 
Is there any professional book for learning mplab x ide that explains x ide more comprehensively?
This post is from Microchip MCU
 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list