This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430FR2033:错误#148:声明与"int movingAverage (int、long、int、int、int)&quot 不兼容;

Guru**** 2345260 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1229235/msp430fr2033-error-148-declaration-is-incompatible-with-int-movingaverage-int-long-int-int-int

器件型号:MSP430FR2033

您好!

我将编写一个移动平均法函数、但得到标题中提到的错误。 我想了解误差的含义以及如何避免它。

下面是代码:

// This part resides in the source file

int movingAverage(int *ptrArrNumbers, long *ptrSum, int pos, int len, int nextNum)
{
    *ptrSum = *ptrSum - ptrArrNumbers[pos] + nextNum;
    ptrArrNumbers[pos] = nextNum;
    return *ptrSum/len;
}

// This part resides in my main source file, but it is not "main.c". 
// It is something else
if(pos0==arr0Length)
        {
            arr0Filled = 1;
            pos0 = 0;
        }

        // If the array has not been fully filled we only consider the number of cases filled with a pressure value
        // to calculate the average pressure (len0). When the array is filled, len0 is the length of the array
        if(arr0Filled == 0)
        {
            len0=pos0+1;
        }
        else
        {
            len0=arr0Length;
        }
        // Moving average
        newAvg0 = movingAvg(arr0Numbers, &sum0, pos0, len0, pressure0);
        pos0++;

谢谢你

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Anish、您好!

    该错误消息与函数 原型和函数定义之间的不匹配相关。  

    我看不出您在代码中的什么位置声明您的函数原型、通常这会在相关头文件中、如果使用单个文件、则会在源代码的开头附近。  您是否可以为  movingAverage 共享函数 prototype *

    此致、
    Brandon Fisher

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您的原型是什么?

    您需要在原型中创建函数参数指针。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我有一个与源文件关联的头文件。 我没跟你说。" 我以为这是必要的,但它本可以帮助。 不管怎样,我看到问题在哪里。 我不匹配源文件和头文件中的参数。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你是对的。