0

メインによって呼び出される関数を作成しました。関数には、ネストされた関数があります。私は以下を使用してコンパイルします:

gcc -o numericalIntegration numericalIntegration.c TrapezoidRule.c SimpsonsRule. GaussQuad.c -fnested-functions

これが私のTrapezoidRuleです:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define pi 3.1415927

//Note: This program was taken from the first practical and adjusted for sin instead of tan(x) and the limits of integration changed to o --> pi/3

double degtorad(double);

float TrapezoidRule(int args) {


int i, j; //Loop index, Counter, Array dimension
float area, rad, Sin[args], coeff; //Return value of the function, Result array, Area, Coefficient
 //TODO: Get table of sin as in Ex. 3

        j=0;

        for (i=0; i<=180; i=i+5) {
                rad = degtorad(i);
                Sin[j] = sin(rad);
                j=j+1;
                }

        area = Sin[0];
        for (i = 1; i < args - 1; i++) {
                area = area + 2.0*Sin[i];
                }
 //Calculating the area using the trapezoid rule and comparing to the real area 
        coeff = degtorad(2.5);
       // area = (area + Sin[dim - 1]) * coeff; 

 //Function to convert degrees to radians
    double degtorad(double arg) {
        return( (pi * arg)/180.0 );
    }

        area = (area + Sin[args - 1]) * coeff;

return area;

}

私が得ているエラーは次のとおりです。

Undefined symbols:
  "_degtorad", referenced from:
      _TrapezoidRule in ccdjbt6m.o
      _TrapezoidRule in ccdjbt6m.o

ld: symbol(s) not found
collect2: ld returned 1 exit status

ネストされた関数を間違って実行していますか?

4

1 に答える 1