delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/07/02:04:15

Date: Sun, 7 Feb 1999 02:02:35 -0500
Message-Id: <199902070702.CAA16749@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <3.0.6.32.19990207015603.008ee100@pop.netaddress.com> (message
from Paul Derbyshire on Sun, 07 Feb 1999 01:56:03 -0500)
Subject: Re: ptrdiff_t
References: <3 DOT 0 DOT 6 DOT 32 DOT 19990207015603 DOT 008ee100 AT pop DOT netaddress DOT com>
Reply-To: djgpp AT delorie DOT com

> What the hell header is ptrdiff_t typedef'd in? I can't find it --
> it isn't in stdlib.h where I thought it would be, and there is no
> info node for it to enable me to track it down that way.

<stddef.h>

You should try "grep" next time.

> I can't even recall a C function that involves ptrdiff_t.

You won't.  ptrdiff_t is the type of the result of subtracting two
pointers, as defined by the compiler.  Normally, when you subtract two
pointers in C, the result is a number - the difference (scaled by the
size of the type the pointers point to - array arithmetic, you know)
between them.  In this example, z would be 50:

	int x[100];
	int *y = &(x[50]);
	ptrdiff_t z = y - x;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019