AnsweredAssumed Answered

Illegal constant expression: copying address to a variable

Question asked by Amit Dhand on Feb 19, 2019
Latest reply on Feb 21, 2019 by Alice_Yang

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.

Outcomes