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.

Posts by Lundin‭

158 posts
85%
+10 −0
Q&A Why can't we mix increment operators like i++ with other operators?

These examples have undefined behavior and unspecified behavior all at once! Operator precedence has nothing to do with the order of execution, see What is the difference between operator precedenc...

posted 4y ago by Lundin‭  ·  edited 4y ago by Lundin‭

Answer
85%
+16 −1
Meta The size of the code format window is much too small.

When posting a lot of code on the site, the "code format window" is much too small: 1 I'm talking about this thing 2 3 4 5 6 7 8 9 10 11 12 13 14 15 The scroll bar appears after...

3 answers  ·  posted 4y ago by Lundin‭  ·  last activity 2y ago by trichoplax‭

85%
+10 −0
Q&A What is CPU endianness?

I was fooling around with the following C code on my trusty old x86 PC: #include <stdint.h> #include <stdio.h> int main (void) { uint32_t u32 = 0xAABBCCDD; uint8_t* ptr = (u...

1 answer  ·  posted 4y ago by Lundin‭  ·  last activity 4y ago by Lundin‭

85%
+10 −0
Q&A Is it undefined behaviour to just make a pointer point outside boundaries of an array without dereferencing it?

Yes, the second line invokes undefined behavior. First of all, according to C17 6.5.2.1 regarding array subscripting, an expression E1[E2] is just "syntactic sugar" for *((E1)+(E2))). So what appli...

posted 4y ago by Lundin‭  ·  edited 4y ago by Lundin‭

Answer
85%
+10 −0
Q&A How to declare variable-length arrays correctly?

C programs are executed from top to bottom. You can't declare a VLA with an uninitialized variable as its size parameter. For the same reason at you can't do this: int x; printf("%d\n",x); scanf...

posted 3y ago by Lundin‭  ·  edited 1y ago by Lundin‭

Answer
84%
+9 −0
Q&A Generate SIGSEGV without undefined behaviour.

SIGSEGV is defined in the C header signal.h. To generate the signal, it should be sufficient to just do raise(SIGSEGV);. As far as I know, this is well-defined behavior.

posted 4y ago by Lundin‭  ·  edited 4y ago by Lundin‭

Answer
84%
+9 −0
Q&A How to properly use malloc?

Should we cast the result of malloc? The cast to the intended type is not necessary in C, since during assignment, the void* returned by malloc can be implicitly converted to any other object poin...

posted 3y ago by Lundin‭  ·  edited 1y ago by Lundin‭

Answer
84%
+9 −0
Q&A Are there references in C?

When reading posts at programming sites such as this one, I frequently encounter people saying things like: "There is no pass-by-reference in C, everything is passed by value." People claiming su...

3 answers  ·  posted 3y ago by Lundin‭  ·  last activity 1y ago by Alexei‭

84%
+9 −0
Meta How do I search for "i++"?

I once wrote this post here: Why can't we mix increment operators like i++ with other operators? When using Codidact search looking for that post, I tried to type i++ in the search but it didn't l...

1 answer  ·  posted 3y ago by Lundin‭  ·  last activity 2y ago by ArtOfCode‭

Question support searching
84%
+14 −1
Q&A What is the difference between operator precedence and order of evaluation?

When doing something simple such as this int a=1; int b=2; int c=3; printf("%d\n", a + b * c); then I was told that operator precedence guarantees that the code is equivalent to a + (b * c)...

1 answer  ·  posted 4y ago by Lundin‭  ·  last activity 7d ago by Lundin‭

84%
+14 −1
Q&A What is do { } while(0) in macros and should we use it?

The sole purpose of the do { } while(0) is to write macros that accommodates to all manner of diverse coding styles. It is quite common not to use braces after if statements, so this is a common co...

posted 4y ago by Lundin‭  ·  edited 4y ago by Lundin‭

Answer
84%
+14 −1
Q&A Is strcpy dangerous and what should be used instead?

Summary (TL;DR) Using strcpy directly on non-sanitized user input is bad, otherwise it's fine. strncpy is a dangerous function that should be avoided. Its presence in your source is a muc...

posted 3y ago by Lundin‭  ·  edited 8mo ago by Lundin‭

Answer
83%
+8 −0
Q&A constructor in C

The warnings just say that you can't pass a string literal with type char[] to a function taking a struct Book* parameter. The function should be declared as: void init_Book_types (const char* tit...

posted 3y ago by Lundin‭  ·  edited 3y ago by Lundin‭

Answer
83%
+8 −0
Q&A memcmp(3) memory containing invalid values

Regarding undefined behavior/uninitialized variables of automatic storage duration First of all there's some misconceptions here. if (x == 0) is UB only because x was declared as a local variable...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
83%
+8 −0
Q&A C naming convention, module trigrams?

For what it's worth, I have some 20 years of experience designing embedded C systems, with large and small code bases both. Code design is some of the hardest things to do, since books about object...

posted 2y ago by Lundin‭  ·  edited 2y ago by Lundin‭

Answer
83%
+8 −0
Q&A Which functions in the C standard library must always be avoided?

It would seem that the C standard library is a collection of diverse functions that pretty much just ended up in the standard by tradition or "accident", rather than through some careful plan or ra...

1 answer  ·  posted 2y ago by Lundin‭  ·  last activity 2y ago by Lundin‭

83%
+8 −0
Q&A How to declare variable-length arrays correctly?

This is meant as a FAQ Q&A regarding variable-length arrays (VLA). The two bugs described below are surprisingly common. I'm trying to use the variable-length arrays feature of C99 (and newe...

1 answer  ·  posted 3y ago by Lundin‭  ·  last activity 1y ago by Lundin‭

83%
+8 −0
Q&A What's the difference between Inheritance and Polymorphism?

Does Inteheritance actually meant return and Polymorphism meant to print out values? This doesn't make the slightest sense... Probably you should forget all you've heard - don't "watch tutoria...

posted 3y ago by Lundin‭

Answer
83%
+8 −0
Code Reviews BMPL: The language I'll bring to life

First of all, I realize that this is mostly a library you've implemented while learning programming, for the sake of learning, which is great. So I would rather not put a "wet blanket" over your at...

posted 3y ago by Lundin‭

Answer
83%
+8 −0
Q&A Is MISRA-C useful outside safety-critical and embedded programming?

It is true that MISRA-C has a heavy focus on embedded system, though it has become somewhat more generic over time. The MISRA guidelines have been changed and improved several times over the years ...

posted 4y ago by Lundin‭  ·  edited 4y ago by ghost-in-the-zsh‭

Answer
83%
+8 −0
Q&A Is MISRA-C useful outside safety-critical and embedded programming?

When discussing best or safest C programming practices with various C gurus on the Internet, the "MISRA-C guidelines for the use of C language in critical systems" often pops up as a source. This ...

1 answer  ·  posted 4y ago by Lundin‭  ·  last activity 4y ago by ghost-in-the-zsh‭

Question c misra-c
83%
+8 −0
Meta Renaming sheets to the more specific google-sheets?

Google Sheets isn't a company name, it's a product name. A tag called google-sheets is perfectly fine. Google doesn't market this product as "Sheets", they market it as "Google Sheets". What is not...

posted 4y ago by Lundin‭  ·  edited 4y ago by Lundin‭

Answer
81%
+7 −0
Q&A Why can't we mix increment operators like i++ with other operators?

I'm experimenting with different operators and have a hard time understanding the outcome of certain expressions. I try to combine the ++ operators with other operators such as assignment in the sa...

1 answer  ·  posted 4y ago by Lundin‭  ·  last activity 4y ago by Lundin‭

81%
+7 −0
Q&A Where to place digit separators in C23?

C23 introduces the digit separator ' which can be placed anywhere inside an integer constant for the purpose of clarity and self-documenting code. These are otherwise ignored by the compiler when d...

2 answers  ·  posted 6mo ago by Lundin‭  ·  last activity 6mo ago by John C‭

81%
+7 −0
Q&A Why is the new auto keyword from C++11 or C23 dangerous?

In older C and C++ standards, the auto keyword simply meant automatic storage duration. As in the compiler automatically handles where the variable is stored, typically on the stack or in a registe...

2 answers  ·  posted 5mo ago by Lundin‭  ·  last activity 3mo ago by celtschk‭