Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

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