I try to compile the below mentioned code in Code-warrior 10.7 but CW throws an error "illegal constant expression"
Code:
uint32_t val1;
uint32_t val2;
uint32_t val2 = (uint32_t)&val2; // Error is specified in this line
void main(void)
{
. // some code
.
.
}
The expression could work out with pointers but I am importing a code from IAR Embedded Workbench to Code-warrior and in IAR Embedded Workbench there is no such problem with such an expression.
Solved! Go to Solution.
Hello Amit,
The compilers are different ,how about use like below:
uint val1;
uint *val2 = &val1;
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello Amit Dhand ,
I test on my side , these code can work well on my side.
Which chip do you used ?
I recommend you create a new project, then copy and paste these code into it , build, check whether can work.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thanks Alice_Yang for your prompt response on the query.
It is my mistake that I didn't recheck the code before posting. The problem still remains the same
Code:
uint32_t val1;
uint32_t val2 = (uint32_t)&val1; // Error is specified in this line: Illegal
void main(void)
{
. // some code
.
.
}
I am using MC9S12ZVCA192 chip for my project.
Screenshot from the CodeWarrior 10.7
Hello Amit,
The compilers are different ,how about use like below:
uint val1;
uint *val2 = &val1;
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------