What is recommended to use, passing a structure as a pointer to const
i.e.
int doCalculations(const MyStruct* my_struct);
or passing the struct
by value, as in,
int doCalculations(MyStruct my_struct);
and why?
In C++ I recall reading somewhere that passing references to const
should be used when the struct
/Class
has a non-trivial constructor. In C although there are no constructors, I imagine it would still take some time to make a local copy of the struct
.