C

C stands for Control.
May 25, 2022 22:34
that's when I compile with -E -traditional
May 25, 2022 22:15
compiling I get error: syntax error in macro parameter list
May 25, 2022 22:14
#if ENABLE_PRINTF
#define PRINT_MESSAGE(...) printf(__VA_ARGS__)
#else
#define PRINT_MESSAGE(...) ((void)0)
#endif
May 25, 2022 22:13
quick question.
May 25, 2022 22:13
oh wow, really empty
May 25, 2022 22:13
weeee
Jan 20, 2022 17:39
is this the proper way to "do nothing"?

int sum(int a, int b) {
#if DO_NOTHING
#else
    return a + b;
#endif
}
Jan 12, 2022 20:05
but* (not how)
Jan 12, 2022 19:06
how *ptr wouldn't be unaligned... so maybe that's not true?
Jan 12, 2022 19:05
because if its packed, b would be unaligned, so accessing it would be unaligned access
Jan 12, 2022 19:04
casting buff to pointer of my_struct, then accessing it, that's bad i take it?
Jan 12, 2022 19:03
I just updated the code, see the bottom of it.
Jan 12, 2022 19:00
@milleniumbug so we'd be looking at something more along the lines of this as being correct?: ideone.com/fwU1Ke
Jan 12, 2022 18:11
@milleniumbug so how can i pull a short out of a char buffer? and how would I set it, the right way?
Jan 12, 2022 18:03
which part?
Jan 12, 2022 17:19
i'm really not trying to be annoying here. hoping yall can bear with me.

my thought is, alignment isn't needed for char *, right. So if I store my data in char buffer, then do someting like `my_struct *ptr = (my_struct *)buff`, then I can use direct access with the pointer to set the value in the buffer, e.g. `ptr->b = 1000;`
Jan 12, 2022 17:08
the cast maybe?
Jan 12, 2022 17:08
@milleniumbug @Kamiccolo I'm assuming something there has to be UB?
Jan 12, 2022 17:07
Jan 12, 2022 17:01
uh oh, go ahead millennium, ruin my day :'D
Jan 12, 2022 16:58
(lets pretend my_struct is packed since I can't edit it anymore)
Jan 12, 2022 16:58
anything wrong with that yet?
Jan 12, 2022 16:57
char buff[50];
memcpy(buff, &s, sizeof(s));
Jan 12, 2022 16:56
typedef struct {
    char a;
    short b;
    int c;
} my_struct;

my_struct s;
Jan 12, 2022 16:54
i'm still dumbfounded about pointer alignment @Kamiccolo lol
Dec 30, 2021 17:00
so order has to matter, as well as optimizing for flash usage
Dec 30, 2021 16:59
this is an embedded system, so eventually all that data in RAM has to get saved to flash, and then loaded after restarts. no concept of file systems or anything
Dec 30, 2021 16:58
hahaha
Dec 30, 2021 16:52
so something along the lines of this: paste.ofcode.org/8kipn8ztDrYTufFDYNFp6m
Dec 30, 2021 16:36
@Kamiccolo so i'm looking at a potential solution. Its a char[] that is the same size as the struct/nested structs, however, there are no structs defined, rather a bunch of #defines that define data type sizes and computed offsets + a lookup table that would allow you to index into the char[].
Dec 30, 2021 16:32
hellocall();
Dec 29, 2021 17:23
@Kamiccolo any big plans for the night of Dec 31?
Dec 29, 2021 17:22
@Curio also, keep in mind, windows newline is \r\n, nix is \n. Some document editors in windows will automatically convert \n to \r\n if you save over the original file, or will add \r\n if you enter a newline in windows editors. if you then feed that file back to nix system, it could cause oddities because nix is expecting \n but the file contains \r\n. This is why i turn on "View > Show Symbols > Show all characters" in notepad++ so I can see what original source is expecting
Dec 29, 2021 17:12
--objective complete--
Dec 29, 2021 17:11
gosh, this post gives me anxiety every time i see it in star board lol
Dec 29, 2021 17:11
Nov 19 '18 at 19:15, by milleniumbug
I like how an unfinished sentence can cause you to have an
Dec 29, 2021 17:04
@Curio yeah, make sure there is a newline at the end of the file and see if you get better results. using *nix apps on windows myself, all my text files end with newlines. even github for windows shows an "warning" icon telling you the file doesn't end with a newline
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
May 4, 2022 15:53
Our SO birthdays are 4 months apart as well. I'm the younger Kevin, I'm much more fun at parties. I use my KVM switch to chat from my imposter account and have conversations with myself, as you can see. Some call it MPD.
May 4, 2022 15:48
Yes, the other guy.
May 4, 2022 15:47
[list(data_bytearray)] might've made it more clear ;)
May 4, 2022 15:46
Right, proper English.
May 4, 2022 15:40
@Kevin I simply did list(data_bytearray). Are the brackets meant to be `, or is there is a reason you added them?
May 4, 2022 15:37
@Kevin "It fails" was directed at the proposed one-liner. And yes, the code works as is, but I wanted to see how it would look as a one liner simply to expose myself to that thought process.
May 4, 2022 15:35
@Kevin well it does lol. I'm not sure if you're familiar with intl hex file format but this is what i'm referring to, github.com/python-intelhex/intelhex/blob/master/intelhex/…
May 4, 2022 15:32
so it fails because bytearray isn't list or tuple. easy fix would be list(data_bytearray), right?
May 4, 2022 15:31
@vaultah wonderful. you're right, depends on the type of ih. ih __setitem__ performs this if using slice, if not isinstance(byte, (list, tuple)):
May 4, 2022 15:24
    address = 0x1000
    for byte in data_bytearray:
        ih[address] = byte
        address += 1
May 4, 2022 15:24
Quick question. Refamiliarizing myself, probably haven't touched python since 2.6/2.7. I feel like this could be turned into a one-liner, but don't know what that would look like, any input?
May 4, 2022 15:21
long time no see
May 4, 2022 15:21
@Kevin , the imposter.