Reputation
547
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
4 14
Impact
~7k people reached

17h
awarded  Good Question
Jul
23
revised Should I initialize C structs via parameter, or by return value?
added 4 characters in body
Jul
21
awarded  Popular Question
Jul
21
awarded  Nice Question
Jul
20
comment Should I initialize C structs via parameter, or by return value?
@cmaster Ok, that's more clear. I can agree with that.
Jul
20
awarded  Commentator
Jul
20
accepted Should I initialize C structs via parameter, or by return value?
Jul
20
comment Should I initialize C structs via parameter, or by return value?
@cmaster Right. Ok. It's just, there's no actual constructors in C. In C++, it's impossible to get an instance of an object without "constructing" it. Constructors are called implicitly when getting an instance, and that's what I was trying to mimic here in C. But you might say that "C is not C++", in which case fine.
Jul
20
comment Should I initialize C structs via parameter, or by return value?
I didn't think copies would be an issue because of en.wikipedia.org/wiki/Copy_elision
Jul
20
comment Should I initialize C structs via parameter, or by return value?
@JacquesB I got " Every component that you build will be different than others. There is an Initialize() function used elsewhere for the struct. Technically speaking, calling it a constructor is misleading."
Jul
20
comment Should I initialize C structs via parameter, or by return value?
@Jefffrey We're in C, so we can't actually have methods. It's not always a direct set of values either. Sometimes initializing a struct is to get values(somehow), and performs some logic to initialize the struct.
Jul
20
revised Should I initialize C structs via parameter, or by return value?
added 86 characters in body
Jul
20
comment Should I initialize C structs via parameter, or by return value?
Ok, seems reasonable. I was under the impression that initializing an object without being able to see what kind of input was initializing it, would lead to confusion. I was trying to follow the concept of data in / data out to produce predictable and testable code. Doing it the other way had seemed to increase coupling as the source file of my struct needed extra dependencies to perform the initialize. You're right though, in that I don't want to rock the boat unless one way is highly preferred over another.
Jul
20
comment Should I initialize C structs via parameter, or by return value?
@gnat This is an explicit question about struct initialization. That thread embodies some of the same rationale I would like to see applied for this particular design decision.
Jul
20
revised Should I initialize C structs via parameter, or by return value?
added 49 characters in body
Jul
20
asked Should I initialize C structs via parameter, or by return value?
Jul
9
comment Does applying a prefix to member variables make sense in C?
@Ryan 90% with a C compiler, the rest with a C++ compiler, and all the C++ code has extern "C" so that it can be called from the C code. The codebase is by and large C with small additions of C++.
Jul
9
asked Does applying a prefix to member variables make sense in C?
Feb
28
awarded  Popular Question
Feb
6
awarded  Yearling