public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* strange warning in gsl_matrix_float_set
@ 2002-10-15  2:04 Ivo Alxneit
  0 siblings, 0 replies; 4+ messages in thread
From: Ivo Alxneit @ 2002-10-15  2:04 UTC (permalink / raw)
  To: GSL-discuss

[-- Attachment #1: Type: TEXT/plain, Size: 1777 bytes --]

i have a wired problem. independently of wether i declare val as float or as double
i get the warning below for the following code:

#include <stdio.h>
#include <gsl/gsl_matrix_float.h>

void read_as_int(gsl_matrix_float *m, size_t n1, size_t n2)
{
	int c1, c2;
	double val;  /* or float val */
	size_t i, j;
	
	for(i=0; i< n1; i++) {
		for(j=0; j<n2; j++) {
			c1=fgetc(stdin);
			c2=fgetc(stdin);
			val=c1 + 256.0*c2;
			gsl_matrix_float_set(m, i, j, val);
		}
	}
}


gcc -O2 -march=i386 -mcpu=i686 -pipe -pedantic -Wall -W -Wmissing-prototypes
 -Wstrict-prototypes -Wtraditional -Wconversion -Wshadow -Wpointer-arith
 -Wcast-qual -Wcast-align -Wwrite-strings -fshort-enums -fno-common -Wnested-externs 
 -Dinline= -g     -I/usr/X11R6/include    -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 
 -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE     -DFUNCPROTO=15 -DNARROWPROTO
 -c -o read_as_int.o read_as_int.c
read_as_int.c: In function `read_as_int':
read_as_int.c:14: warning: passing arg 4 of `gsl_matrix_float_set' as `float' rather 
than `double' due to prototype
rm -f lav2pnm
gcc -o lav2pnm -O2 -march=i386 -mcpu=i686 -pipe -pedantic -Wall -W -Wmissing-prototypes
 -Wstrict-prototypes -Wtraditional -Wconversion -Wshadow -Wpointer-arith
 -Wcast-qual -Wcast-align -Wwrite-strings -fshort-enums -fno-common -Wnested-externs
 -Dinline= -g     -L/usr/X11R6/lib lav2pnm.o      read_as_int.o      write_pgm.o      
 write_ppm.o      HSV_to_RGB.o      help.o      -lgsl -lgslcblas -lm 

what am i doing wrong here?
-- 
Dr. Ivo Alxneit
Laboratory for Solar Technology   phone: +41 56 310 4092
CH-5232 Villigen                    fax: +41 56 310 2624
Paul Scherrer Institute          http://solar.web.psi.ch
Switzerland                        gnupg key: 0x515E30C7

[-- Attachment #2: Type: APPLICATION/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange warning in gsl_matrix_float_set
       [not found]   ` <E182QR9-0005gW-00@ultra16.uk2net.com>
@ 2002-10-20  6:06     ` Brian Gough
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Gough @ 2002-10-20  6:06 UTC (permalink / raw)
  To: Ivo Alxneit; +Cc: gsl-discuss

Ivo Alxneit writes:
 > well according to the mainual -Wconversion deals with warnings due to
 > signed/unsigned variables. i get a waring due to float/double even
 > though the prototype in gsl_matrix_float.h is

`-Wconversion'
     Warn if a prototype causes a type conversion that is different
     from what would happen to the same argument in the absence of a
     prototype.

In the absence of a prototype float is promoted to double, as in the
old K&R C, hence the warning.  The float/double warning always occurs
with -Wconversion, so I only use that option for occassional checks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange warning in gsl_matrix_float_set
  2002-10-15 15:06 ` Brian Gough
@ 2002-10-17 23:16   ` Ivo Alxneit
       [not found]   ` <E182QR9-0005gW-00@ultra16.uk2net.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Ivo Alxneit @ 2002-10-17 23:16 UTC (permalink / raw)
  To: bjg; +Cc: GSL-discuss

[-- Attachment #1: Type: TEXT/plain, Size: 1475 bytes --]

On 15 Oct, Brian Gough wrote:
> Ivo Alxneit writes:
> 
>  > gcc -O2 -march=i386 -mcpu=i686 -pipe -pedantic -Wall -W -Wmissing-prototypes
>  >  -Wstrict-prototypes -Wtraditional -Wconversion -Wshadow -Wpointer-arith
>  >  -Wcast-qual -Wcast-align -Wwrite-strings -fshort-enums -fno-common -Wnested-externs 
>  >  -Dinline= -g     -I/usr/X11R6/include    -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 
>  >  -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE     -DFUNCPROTO=15 -DNARROWPROTO
>  >  -c -o read_as_int.o read_as_int.c
>  > read_as_int.c: In function `read_as_int':
>  > read_as_int.c:14: warning: passing arg 4 of `gsl_matrix_float_set' as `float' rather 
>  > than `double' due to prototype
> 
> See the section on -Wconversion in the GCC Manual for a description of
> the warning.
well according to the mainual -Wconversion deals with warnings due to
signed/unsigned variables. i get a waring due to float/double even
though the prototype in gsl_matrix_float.h is

void    gsl_matrix_float_set(gsl_matrix_float * m, const size_t i, const
size_t j, const float x);

i.e. const float for the fourth argument. gcc sees a double in the
prototype. am i really supposed to use a cast to get rid of the warning?
-- 
Dr. Ivo Alxneit
Laboratory for Solar Technology   phone: +41 56 310 4092
CH-5232 Villigen                    fax: +41 56 310 2624
Paul Scherrer Institute          http://solar.web.psi.ch
Switzerland                        gnupg key: 0x515E30C7

[-- Attachment #2: Type: APPLICATION/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange warning in gsl_matrix_float_set
       [not found] <E181NdC-00048U-00@ultra16.uk2net.com>
@ 2002-10-15 15:06 ` Brian Gough
  2002-10-17 23:16   ` Ivo Alxneit
       [not found]   ` <E182QR9-0005gW-00@ultra16.uk2net.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Brian Gough @ 2002-10-15 15:06 UTC (permalink / raw)
  To: Ivo Alxneit; +Cc: GSL-discuss

Ivo Alxneit writes:

 > gcc -O2 -march=i386 -mcpu=i686 -pipe -pedantic -Wall -W -Wmissing-prototypes
 >  -Wstrict-prototypes -Wtraditional -Wconversion -Wshadow -Wpointer-arith
 >  -Wcast-qual -Wcast-align -Wwrite-strings -fshort-enums -fno-common -Wnested-externs 
 >  -Dinline= -g     -I/usr/X11R6/include    -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L 
 >  -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE     -DFUNCPROTO=15 -DNARROWPROTO
 >  -c -o read_as_int.o read_as_int.c
 > read_as_int.c: In function `read_as_int':
 > read_as_int.c:14: warning: passing arg 4 of `gsl_matrix_float_set' as `float' rather 
 > than `double' due to prototype

See the section on -Wconversion in the GCC Manual for a description of
the warning.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-10-20 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15  2:04 strange warning in gsl_matrix_float_set Ivo Alxneit
     [not found] <E181NdC-00048U-00@ultra16.uk2net.com>
2002-10-15 15:06 ` Brian Gough
2002-10-17 23:16   ` Ivo Alxneit
     [not found]   ` <E182QR9-0005gW-00@ultra16.uk2net.com>
2002-10-20  6:06     ` Brian Gough

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).