home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c,comp.sys.amiga.programmer
- Subject: Re: pointer conversion error
- Date: 26 Mar 96 18:18:18 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.827864298@rscernix>
- References: <4j39n1$mh4@news.xs4all.nl> <676.6658T1354T436@mistral.co.uk> <4j865t$npa@btmpjg.god.bel.alcatel.be>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4j865t$npa@btmpjg.god.bel.alcatel.be> barnhoorn@nlev00 () writes:
-
- >In article <676.6658T1354T436@mistral.co.uk>, ghira@mistral.co.uk (Adam Atkinson) writes:
- >>On 24-Mar-96 10:55:29, Falstaff said:
- >>>ghira@mistral.co.uk (Adam Atkinson) writes:
- >>
- >>>>my c compiler (SAS/C version 6.56) creates a warning about the following:
- >>
- >>>> printf("%u %u %u \n", i, l, h);
- >>
- >>>>three.c 36 Warning 104: conversion from pointer to const/volatile to pointer
- >>>>to non-const/volatile
- >>
- >>>>What am I doing wrong? i,l and h are unsigned longs.
- >>
- >>>Seems like the printf() prototype is missing. #include <stdio.h>
- >>
- >>actually, it turns out I should have used %lu not %u. oops
- >>
- >.when this is true, then the compiler is actually checking the
- >string you give as first parameter of printf() !!????? Very strange.
-
- Not strange at all. The most popular compiler in the Unix world, gcc,
- does this kind of checking, if asked:
-
- ues5:~/tmp 11> cat test.c
- #include <stdio.h>
-
- int main(void)
- {
- static unsigned long i, l, h;
- printf("%u %u %u \n", i, l, h);
- return 0;
- }
- ues5:~/tmp 12> gcc -Wall test.c
- test.c: In function `main':
- test.c:6: warning: unsigned int format, different type arg (arg 2)
- test.c:6: warning: unsigned int format, different type arg (arg 3)
- test.c:6: warning: unsigned int format, different type arg (arg 4)
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-