Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Profiling Civserver again
Home

[Freeciv-Dev] Re: Profiling Civserver again

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Profiling Civserver again
From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
Date: Wed, 1 Aug 2001 22:43:53 -0700 (PDT)

On Thu, 2 Aug 2001, Vasco Alexandre Da Silva Costa wrote:
> 
> Of course this sentence is unclear. Do they mean you must do it like this
> if you want to use 0?:
> 
> if (p==0)
> if (p!=0)

If you read it a bit more, they make it clear.  if(p) is equivilant to
if(p!=0) and will work.  However, if you read Q 5.17, they do list a bunch of
machines which have null pointers which do not have the value 0.  It's just
that the C compile is supposed to realize that in a pointer context 0 means
NULL, whatever value that happens to be.  The only problem is when you try to
store a pointer inside another variable type, like a long, or use a fuction
with no prototype so the compile doesn't know you are in a pointer context.

for instance..

int *p = NULL;
long l = p;
if(l != 0)  printf("your machine has non-zero null pointers)

or...

main()
{
    function_with_no_prototype(NULL);  // Will say "NULL not passed"
                                       // if machine has non-zero null pointers
}
int function_with_no_prototype(int *p)
{
  if(p!=0) printf("NULL not passed\n");
}




[Prev in Thread] Current Thread [Next in Thread]