Re: pid_t data type



On Mar 18, 3:02 pm, Rainer Weikusat <rweiku...@xxxxxxxxxxx> wrote:
"jason.cipri...@xxxxxxxxx" <jason.cipri...@xxxxxxxxx> writes:
On Mar 18, 5:48 am, Rainer Weikusat <rweiku...@xxxxxxxxxxx> wrote:
[snip]

Does it say somewhere that pid_t will never be a pointer type, or some
other type, like a float (which, while strange, is fine since it's
hidden behind the typedef)?

It does:

<URL:http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/types.h.ht...>

I see. It also says:

"The implementation shall support one or more programming environments
in which the widths of blksize_t, pid_t, size_t, ssize_t, suseconds_t,
and useconds_t are no greater than the width of type long."

If you take that to mean that *all* supported "programming
environments" have pid_t with width no greater than the width of type
long, then it *is* save to store pid_t's in a long. Is there something
that indicates that it's not?

If that's the case the only two issues with using long instead of
pid_t are:

1) If that standard changes some day, and

2) Using pid_t clearly indicates that the variable, function
parameter, etc., is meant to hold a process ID, and not some arbitrary
integer with another meaning. Saves on documentation.

It seems pretty simple, what is the argument about? If you are
prepared to face the consequences of 1 and 2 then you'd use longs, and
if you don't want to think about it then you'd use pid_t's. I think #2
is a big reason to use pid_t's. I also can't think of a compelling
reason to do it otherwise. If you are trying to store pid_t's as data
in a file, it may be more painless to just store them as text strings
(like the string "58123")... ?

Jason

.



Relevant Pages

  • Re: negative number evaluating greater than string.size()
    ... >> for such strings in the first place? ... > low-level design error. ... That you only want to store non-negative ... values is not such a reason. ...
    (comp.lang.cpp)
  • Re: Drawbacks of same user name logging in multiple times?
    ... The reason is that they have multiple eyecare stores and they currently log ... store number, such as "024-Exam01" and a common or similar password. ... Gregg Hill ...
    (microsoft.public.windows.terminal_services)
  • RE: HeapFree() Failure
    ... HeapAllocand HeapFreecalls with GlobalAlloc() and GlobalFree ... globally defined strings it declares like so: ... Sixteen bytes are successfully allocated to store pointers to ...
    (microsoft.public.windowsce.embedded)
  • Re: RGB LEDs
    ... or ask for 'pale goldenrod' and the LEDs are set that way. ... those strings... ... You don't need to store the entire table as raw ASCII. ...
    (sci.electronics.design)
  • HeapFree() Failure
    ... globally defined strings it declares like so: ... Sixteen bytes are successfully allocated to store pointers to ... All this stuff it does in WndProc_OnCreate(lpWEA wea), ...
    (microsoft.public.windowsce.embedded)