Post ATD46SlKmUrrR7P7Bo by pgv@omglol.fun
(DIR) More posts by pgv@omglol.fun
(DIR) Post #ATD3aocdyI87y0FTFY by pgv@omglol.fun
2023-03-02T15:45:12.942632Z
0 likes, 0 repeats
Can we all agree for a second that #cLang #macros are #evil? I know that it’s all just code for: I’m too #stupid to #program, but it still seems like a needless #footGun
(DIR) Post #ATD46SlKmUrrR7P7Bo by pgv@omglol.fun
2023-03-02T15:50:56.100567Z
0 likes, 0 repeats
In other news, I’ve fixed my #code so that 1+1 = 2 no matter which order you happen to add the 1s in. 😞
(DIR) Post #ATPJm2LhMyD81BPkSu by orbifx@mastodon.social
2023-03-08T09:14:03Z
0 likes, 0 repeats
@pgv they aren't good or evil, they are either used or abused :)
(DIR) Post #ATPJm30SvOow3cUJ0a by pgv@omglol.fun
2023-03-08T13:43:02.614014Z
0 likes, 0 repeats
@orbifxYeah, for sure. I was frustrated because it seems needlessly hard to use well. For a complex macro that doesn't just work, you gotta find a simple enough case, change the compiler over, find it in the giant preprocessed file, manually evaluate the expression.... Yadda Yadda Yadda.It's just dumb.
(DIR) Post #ATPRzXvk3rfnMcE4nY by orbifx@mastodon.social
2023-03-08T15:07:18Z
0 likes, 0 repeats
@pgv what is it you want the macro to do?
(DIR) Post #ATPRzYVBw41t8YoO3M by pgv@omglol.fun
2023-03-08T15:15:07.846969Z
0 likes, 0 repeats
@orbifx To be sure, there is nothing to fix, the macro was just missing parentheses. All I needed it to do was shift, mask and typecast a 64b int. I just wrote it, spot checked it, and went on my merry way. #define FILT_PA(mask) ((uint32_t)(((mask) >> 32) & (uint64_t)(0xFFFFFFFF)))#define FILT_PB(mask) ((uint32_t)(((mask) >> 0) & (uint64_t)(0xFFFFFFFF)))Actually using it in the code base though involved logic-ORing large numbers of ports, and the microcontroller just wasn’t changing state when I expected – the order mattered. Again, it’s all fine now, but tracking down the bug was a lot of work for no user-facing value.
(DIR) Post #ATPTWX10aI1i2Iyw6a by orbifx@mastodon.social
2023-03-08T15:18:27Z
0 likes, 0 repeats
@pgv was asking to understand the case.tried to write this a regular #c function to see if this compiler can optimise it (inline) while benefiting from better compilation checks & errors?
(DIR) Post #ATPTWXYKaOgJheZY2q by pgv@omglol.fun
2023-03-08T15:32:18.390074Z
0 likes, 0 repeats
@orbifx I really appreciate your curiosity here :). Just FYI, there are a couple of extra ‘gotchas’. This is for work, and I’ve got a mandated compiler (IAR v5.something) and more than 10y/o. So, even if your does a nice job of this, I still may not be able to use it.