Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for Pete W
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #281518 |
you could use [strlcpy()](https://linux.die.net/man/3/strlcpy). It's not hard to re-create if not available. If destination is fixed size in a way that allows it, use the sizeof() operator. E.g. `char dst[FIXED_SIZE]; strlcpy(dst, src, sizeof(dst))` (more) |
— | over 3 years ago |
Comment | Post #280449 |
can you have GCC generate both ELF and another format side by side? I found intel .hex easy to work with (more) |
— | almost 4 years ago |
Comment | Post #279895 |
Fair enough, I missed that.
I learned it from looking at the way headers in some system macros were written, and have been doing it ever since. I also got into the habit of using do{} to call attention to there being a block, but this comes from having done a bunch of Perl, where curlies have mult... (more) |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 |
Post edited: |
— | almost 4 years ago |
Edit | Post #279895 | Initial revision | — | almost 4 years ago |
Answer | — |
A: What is do { } while(0) in macros and should we use it? Reasons to use the construct `#define FOO(x) do{...} while(0);`: 1. As mentioned above, doing so solves the problem of ``` if (...) FOO(y); ``` 1. You can declare variables inside the block, and they harmlessly go out of scope at the end of the block. Without the `do{}` block, ... (more) |
— | almost 4 years ago |