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:MSP430FR2033:错误#148:声明与"函数名"(在"..\source file name 行声明)

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1201984/msp430fr2033-msp430fr2033-error-148-declaration-is-incompatible-with-function-name-declared-at-line-x-of-source-file-name

器件型号:MSP430FR2033

您好!

我想知道错误#148是什么。 我想知道它是如何发生的。 我想知道如何缓解它。 我在代码中添加了有关问题所在的注释。 注释中也有一些提示信息。

/*
 * TF.c
 *
 *  Created on: Feb 21, 2023
 *      Author: anish.patel
 */

#include "TF.h"
#include "serial.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>


//=====================================
//
//=====================================
// Change state and perform entry processing
typedef enum
{
    True,
    False,
}TF_e;
static TF_e mTF;

//===================================
//
//====================================
// Return True or False or do nothing
static void ReturnBool(TF_e TF) // I am getting an error #148 from here. 
                                // CCS says declaration is incompatible with the function
{
    switch(TF)
    {
    case True:
       mTF = TF;
       SendStr("True");
       return  mTF;
       break;
    case False:
        mTF = TF;
       SendStr("False");
       return mTF;
       break;
    default:
        mTF = TF;
        break;

    }
}

//=========================================
//
//=========================================
// External function to be called out in other libraries
void ChangeBool(void)
{
    ReturnBool(True);
}

谢谢你

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

    您将其声明为无效-即它不返回任何内容-然后在 switch 语句中包含 return 语句。

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

    还有哪些其他选项?  是否有返回某个值的函数类型?  

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

    如果不使用 void、只需使用要返回的类型:

    静态 TF_e ReturnBool (TF_e TF)

    这都是标准 C