Declarations:
/* Olson and Salop */
double os(double,double,short int);
/* Olson, Salop, and Taulberg */
double ost(double,double,short int,int,int);
Code snippets:
/* Olson and Salop */
double os(double rx,double ita,short int charge)
{
double a=0.0;
double b=0.0;
a=18.26/sqrt((double)charge);
b=1.872*sqrt(ita/(double)charge);
return a*exp(-b*rx);
}
/* Olson, Salop, and Taulberg */
double ost(double rx,double ita,short int charge,int PQN,int AQN)
{
/* AQN - azimuthal quantum number */
/* PQN - principle quantum number */
return os(rx,ita,charge)*exp(0.5*(log(2.0*AQN+1.0)-lgamma((double)PQN-AQN)-lgamma((double)(PQN+AQN+1)))+lgamma((double)PQN)); /* line 64 */
}
Compiler flags:
CC=gcc
WFLAGS=-W \
-Wall \
-Werror \
-Wshadow \
-Wcast-qual \
-Wcast-align \
-Wconversion \
-Wwrite-strings \
-Wpointer-arith \
-Wnested-externs \
-Wstrict-prototypes \
-Wmissing-prototypes
CFLAGS=$(WFLAGS) \
-g \
-O2 \
-ansi \
-pedantic \
-Dinline= \
-fno-common \
-fshort-enums
-fno-common \
-fshort-enums
Compiler:
$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler warning/error:
$ make
gcc -W -Wall -Werror -Wshadow -Wcast-qual -Wcast-align -Wconversion -Wwrite-strings -Wpointer-arith -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -g -O2 -ansi -pedantic -Dinline= -fno-common -fshort-enums -c couplings.c
cc1: warnings being treated as errors
couplings.c: In function 'ost':
couplings.c:64: warning: passing argument 3 of 'os' with different width due to prototype
make: *** [couplings.o] Error 1
Why is this warning occurring? Everything for argument 3 of os()
is declared as short int
. I know I can get rid of -Wconversion
to prevent the warning, but I'd rather address the real cause. And no, this is not homework.
Thanks.