# Mailinglist Archive: opensuse (1839 mails)

< Previous | Next > |

##### [opensuse] C help - compile errors on simple function - need help

- From: "David C. Rankin" <drankinatty@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Sep 2010 19:15:48 -0500
- Message-id: <4C9A9C34.7080403@xxxxxxxxxxxxxxxxxx>

Guys,

I have a function I just added to a little program the does some

atmospheric

calculation and it is giving me errors that variables I have just defined in the

function are unused. My guess is that I'm screwing up the last 'if' statement

because it isn't seeing the P (pressure) calculation.

I know this is probably very basic and I'm violating some rule, but

this is a

case where I could stare at it and google for hours over something simple, so I

thought I would ask for help curing my CRI.

The build line and the errors are:

19:08 alchemy:~/dev/prg/ccpp/src-c/prj/test> gcc -o atm -Wall -lm -std=c99

atmtable.c

atmtable.c: In function ‘fn_atmPress’:

atmtable.c:173: warning: unused variable ‘M’

atmtable.c:172: warning: unused variable ‘g0’

atmtable.c:171: warning: unused variable ‘R’

atmtable.c:170: warning: unused variable ‘hb’

atmtable.c:169: warning: unused variable ‘h’

atmtable.c:168: warning: unused variable ‘Lb’

atmtable.c:167: warning: unused variable ‘Tb’

atmtable.c:166: warning: unused variable ‘Pb’

atmtable.c:182: warning: unused variable ‘M’

atmtable.c:181: warning: unused variable ‘g0’

atmtable.c:180: warning: unused variable ‘R’

atmtable.c:179: warning: unused variable ‘hb’

atmtable.c:178: warning: unused variable ‘h’

atmtable.c:177: warning: unused variable ‘Lb’

atmtable.c:176: warning: unused variable ‘Tb’

atmtable.c:175: warning: unused variable ‘Pb’

The function declaration is:

double fn_atmPress(double arry[], int SIflag) {

/* Comment Block

SIflag=1 for Metric, anything else for English

arry [hb, h, Pb, Tb, Lb]

Metric units:

Pb = Static pressure (pascals)

Tb = Standard temperature (K)

Lb = Standard temperature lapse rate -0.0065 (K/m) in ISA

h = Height above sea level (meters)

hb = Height at bottom of layer b (meters; e.g., h1 = 11,000 meters)

R = Universal gas constant for air: 8.31432 N·m /(mol·K)

g0 = Gravitational acceleration (9.80665 m/s2)

M = Molar mass of Earth's air (0.0289644 kg/mol)

English units:

Pb = Static pressure (inches of mercury, inHg)

Tb = Standard temperature (K)

Lb = Standard temperature lapse rate (K/ft)

h = Height above sea level (ft)

hb = Height at bottom of layer b (feet; e.g., h1 = 36,089 ft)

R = Universal gas constant; using feet, kelvins, and (SI) moles:

8.9494596×10-4 lb·ft2/(lbmol·K·s2)

g0 = Gravitational acceleration (32.17405 ft/s2)

M = Molar mass of Earth's air (28.9644 lb/mol)

*/

// Initialize all variable to 0.0

double P = 0.0;

double Pb = 0.0;

double Tb = 0.0;

double Lb = 0.0;

double h = 0.0;

double hb = 0.0;

double R = 0.0;

double g0 = 0.0;

double M = 0.0;

// Test SIflag and set variables for Metric or English units

if (SIflag == 1) {

double Pb = arry[3];

double Tb = arry[4];

double Lb = arry[5];

double h = arry[2];

double hb = arry[1];

double R = 8.31432;

double g0 = 9.80665;

double M = 0.0289644;

} else {

double Pb = arry[3];

double Tb = arry[4];

double Lb = arry[5];

double h = arry[2];

double hb = arry[1];

double R = 8.9494596e-4;

double g0 = 32.17405;

double M = 28.9644;

}

// testing output

printf("\nUsing the following values for pressure calc:\n\n");

printf(" Pb = %13.6f\n", Pb);

printf(" Tb = %13.6f\n", Tb);

printf(" Lb = %13.6f\n", Lb);

printf(" h = %13.6f\n", h);

printf(" hb = %13.6f\n", hb);

printf(" R = %13.6f\n", R);

printf(" g0 = %13.6f\n", g0);

printf(" M = %13.6f\n", M);

// Test Lapse Rate and perform pressure calculation accordingly

if (Lb == 0.0)

P = Pb * exp( (-g0*M*(h-hb))/(R*Tb) );

else

P = Pb * pow( Tb/(Tb+Lb*(h-hb)), (g0*M)/(R*Lb) );

return P;

}

I have also tried with - if ( islessgreater(Lb,0.0))

but I get the same errors. The == operator shouldn't throw an error with NaN

anyway. See:

http://www.gnu.org/s/libc/manual/html_node/FP-Comparison-Functions.html

P.S. CRI = cranal rectal inversion :p

--

David C. Rankin, J.D.,P.E.

Rankin Law Firm, PLLC

510 Ochiltree Street

Nacogdoches, Texas 75961

Telephone: (936) 715-9333

Facsimile: (936) 715-9339

www.rankinlawfirm.com

--

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx

For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

I have a function I just added to a little program the does some

atmospheric

calculation and it is giving me errors that variables I have just defined in the

function are unused. My guess is that I'm screwing up the last 'if' statement

because it isn't seeing the P (pressure) calculation.

I know this is probably very basic and I'm violating some rule, but

this is a

case where I could stare at it and google for hours over something simple, so I

thought I would ask for help curing my CRI.

The build line and the errors are:

19:08 alchemy:~/dev/prg/ccpp/src-c/prj/test> gcc -o atm -Wall -lm -std=c99

atmtable.c

atmtable.c: In function ‘fn_atmPress’:

atmtable.c:173: warning: unused variable ‘M’

atmtable.c:172: warning: unused variable ‘g0’

atmtable.c:171: warning: unused variable ‘R’

atmtable.c:170: warning: unused variable ‘hb’

atmtable.c:169: warning: unused variable ‘h’

atmtable.c:168: warning: unused variable ‘Lb’

atmtable.c:167: warning: unused variable ‘Tb’

atmtable.c:166: warning: unused variable ‘Pb’

atmtable.c:182: warning: unused variable ‘M’

atmtable.c:181: warning: unused variable ‘g0’

atmtable.c:180: warning: unused variable ‘R’

atmtable.c:179: warning: unused variable ‘hb’

atmtable.c:178: warning: unused variable ‘h’

atmtable.c:177: warning: unused variable ‘Lb’

atmtable.c:176: warning: unused variable ‘Tb’

atmtable.c:175: warning: unused variable ‘Pb’

The function declaration is:

double fn_atmPress(double arry[], int SIflag) {

/* Comment Block

SIflag=1 for Metric, anything else for English

arry [hb, h, Pb, Tb, Lb]

Metric units:

Pb = Static pressure (pascals)

Tb = Standard temperature (K)

Lb = Standard temperature lapse rate -0.0065 (K/m) in ISA

h = Height above sea level (meters)

hb = Height at bottom of layer b (meters; e.g., h1 = 11,000 meters)

R = Universal gas constant for air: 8.31432 N·m /(mol·K)

g0 = Gravitational acceleration (9.80665 m/s2)

M = Molar mass of Earth's air (0.0289644 kg/mol)

English units:

Pb = Static pressure (inches of mercury, inHg)

Tb = Standard temperature (K)

Lb = Standard temperature lapse rate (K/ft)

h = Height above sea level (ft)

hb = Height at bottom of layer b (feet; e.g., h1 = 36,089 ft)

R = Universal gas constant; using feet, kelvins, and (SI) moles:

8.9494596×10-4 lb·ft2/(lbmol·K·s2)

g0 = Gravitational acceleration (32.17405 ft/s2)

M = Molar mass of Earth's air (28.9644 lb/mol)

*/

// Initialize all variable to 0.0

double P = 0.0;

double Pb = 0.0;

double Tb = 0.0;

double Lb = 0.0;

double h = 0.0;

double hb = 0.0;

double R = 0.0;

double g0 = 0.0;

double M = 0.0;

// Test SIflag and set variables for Metric or English units

if (SIflag == 1) {

double Pb = arry[3];

double Tb = arry[4];

double Lb = arry[5];

double h = arry[2];

double hb = arry[1];

double R = 8.31432;

double g0 = 9.80665;

double M = 0.0289644;

} else {

double Pb = arry[3];

double Tb = arry[4];

double Lb = arry[5];

double h = arry[2];

double hb = arry[1];

double R = 8.9494596e-4;

double g0 = 32.17405;

double M = 28.9644;

}

// testing output

printf("\nUsing the following values for pressure calc:\n\n");

printf(" Pb = %13.6f\n", Pb);

printf(" Tb = %13.6f\n", Tb);

printf(" Lb = %13.6f\n", Lb);

printf(" h = %13.6f\n", h);

printf(" hb = %13.6f\n", hb);

printf(" R = %13.6f\n", R);

printf(" g0 = %13.6f\n", g0);

printf(" M = %13.6f\n", M);

// Test Lapse Rate and perform pressure calculation accordingly

if (Lb == 0.0)

P = Pb * exp( (-g0*M*(h-hb))/(R*Tb) );

else

P = Pb * pow( Tb/(Tb+Lb*(h-hb)), (g0*M)/(R*Lb) );

return P;

}

I have also tried with - if ( islessgreater(Lb,0.0))

but I get the same errors. The == operator shouldn't throw an error with NaN

anyway. See:

http://www.gnu.org/s/libc/manual/html_node/FP-Comparison-Functions.html

P.S. CRI = cranal rectal inversion :p

--

David C. Rankin, J.D.,P.E.

Rankin Law Firm, PLLC

510 Ochiltree Street

Nacogdoches, Texas 75961

Telephone: (936) 715-9333

Facsimile: (936) 715-9339

www.rankinlawfirm.com

--

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx

For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous | Next > |