2024-02-21 08:16 AM
As title suggest.
If I do
int my_var;
my_var = 0b01;
my_var stays 0
Instead with
int my_var;
my_var = 0x01;
Everything works
STM32CubeIDE
Version: 1.14.1
Build: 20064_20240111_1413 (UTC)
2024-02-21 11:44 PM
That could be the issue as I'm using IAR as well and I've been using the 0b notation forever. How do I check if CubeIDE has it implemented?
2024-02-21 11:50 PM - edited 2024-02-21 11:51 PM
So I have a data structure in the form of
struct registri{
uint16_t reg1;
} data_read;
And I use it inside a function like
void com_gateway(struct registri *dati){
dati->reg1 = 0b01;
}
Even if I use a switch case like
switch(dati->reg1) {
case 0b0:
break;
case 0b1:
break;
}
Seems to not match the cases. Instead, using 0x0 and 0x1 everything works fine (or 0, 1, 2 etc)
I'm using an STM32F091
2024-02-22 02:05 AM
@nico23 wrote:How do I check if CubeIDE has it implemented?
You would get an error (or, at least, a warning).
2024-02-22 02:06 AM - edited 2024-02-22 02:07 AM
Again, you need to show a minimum but complete example which illustrates the issue.
Code snippets out of context tell us very little - especially when they're not even the code you're actually running.
2024-02-22 02:36 AM
The issue here is that on the MCU GG Compiler I've the -fcommon flag active because GCC10 enforce some warning as error and won't make compile/link
Please refer to this. So, I could be warnings/errors, but maybe they're stripped because the flag?
2024-02-22 04:43 AM
As that link says, the situation arises from bad code - so would be better to fix the underlying issue that mask it behind -fcommon.
Similarly with binary constants - they are* a non-portable extension, so best avoided if you don't want to run into problems when porting to new tools.
* Or were until very recently.