Ralph Corderoy | 28 Jan 2012 14:55
Picon

Patch for Pointer Difference Compiler Warnings.

Hi,

New subscriber to the list...  Have just built from CVS and got a few
compiler warnings;  difference between pointers yields a long not an
int.  Patch below from `cvs di -u'.

Cheers, Ralph.

Index: junk.c
===================================================================
RCS file: /cvsroot/nail/nail/junk.c,v
retrieving revision 1.54
diff -u -u -r1.54 junk.c
--- junk.c	14 Sep 2008 11:15:38 -0000	1.54
+++ junk.c	28 Jan 2012 13:45:41 -0000
 <at>  <at>  -1037,7 +1037,7  <at>  <at> 
 	float	a = 1, b = 1, r;

 	if (verbose)
-		fprintf(stderr, "Examining message %d\n", m - &message[0] + 1);
+		fprintf(stderr, "Examining message %ld\n", m - &message[0] + 1);
 	for (i = 0; i < BEST; i++) {
 		best[i].dist = 0;
 		best[i].prob = -1;
 <at>  <at>  -1064,7 +1064,7  <at>  <at> 
 	}
 	r = a+b > 0 ? a / (a+b) : 0;
 	if (verbose)
-		fprintf(stderr, "Junk probability of message %d: %g\n",
+		fprintf(stderr, "Junk probability of message %ld: %g\n",
(Continue reading)

Křištof Želechovski | 28 Jan 2012 16:56
Picon
Gravatar

Re: Patch for Pointer Difference Compiler Warnings.

Dnia sobota, 28 stycznia 2012 13:55:48 Ralph Corderoy pisze:
> fprintf(stderr, "Examining message %ld\n", m - &message[0] + 1);

That should use %zd.

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
Ralph Corderoy | 28 Jan 2012 17:24
Picon

Re: Patch for Pointer Difference Compiler Warnings.

Hi Křištof,

> Dnia sobota, 28 stycznia 2012 13:55:48 Ralph Corderoy pisze:
> > fprintf(stderr, "Examining message %ld\n", m - &message[0] + 1);
> 
> That should use %zd.

The `z' length modifier isn't used yet anywhere in the codeAFAICS,
perhaps that's deliberate.  IIRC pointer subtraction yields an
implementation defined short, int, or long.  It could be cast to be
sure?

    fprintf(stderr, "Examining message %ld\n",
        (long)(m - &message[0] + 1));

Cheers, Ralph.

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
nail-devel mailing list
nail-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nail-devel

Gmane