Re: Choosing function parameter types - pointers or objects?



Richard Heathfield <invalid@xxxxxxxxxxxxxxx> writes:
ballpointpenthief said:
I know this question is a bit vague, but I was wondering about any
rules / guidelines / style issues, for when to use pointers, and when
not to, in your function parameters?

If it's a native type (int, short, long, double, that sort of thing), pass
it in raw unless you need to hack its value. Anything else - structs and
stuff - pass a pointer.

I wouldn't hesitate to pass a *small* structure directly.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: Choosing function parameter types - pointers or objects?
    ... rules / guidelines / style issues, for when to use pointers, and when ... not to, in your function parameters? ... If it's a native type, ... Anything else - structs ...
    (comp.lang.c)
  • Re: Choosing function parameter types - pointers or objects?
    ... rules / guidelines / style issues, for when to use pointers, and when ... not to, in your function parameters? ... If it's a native type (int, short, long, double, that sort of thing), pass ...
    (comp.lang.c)
  • Re: Choosing function parameter types - pointers or objects?
    ... rules / guidelines / style issues, for when to use pointers, and when ... not to, in your function parameters? ... If it's a native type, ... I do accept struct tm by value from localtimeto populate my local struct tm when I'm playing with time stuff. ...
    (comp.lang.c)
  • Re: Equivalency of Integral Pointers
    ... native type conversion based on the size of the native type. ... must all integral pointers have the same size? ... representation as an int* or long*. ...
    (comp.lang.c)
  • Re: Consideration on pointer declarations
    ... to pointers like often found in function parameters. ... C's unique type declaration syntax doesn't really help in separating things ... had to fire up another machine with a known working cdecl, ...
    (comp.lang.c)