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.

[参考译文] 编译器/MSP432P401R:结构体声明有问题

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/610393/compiler-msp432p401r-problem-with-a-structure-declaration

器件型号:MSP432P401R

工具/软件:TI C/C++编译器

您好! 我正在尝试将 W5500以太网芯片的驱动程序与我在 Code Composer Studio 7中的 MSP432控制器上的代码进行集成、并进行了最新的更新。 可以在 GitHub上找到该驱动程序。 问题是由于 EtherNet/wizchip_conf. nin 中的 struct 声明、程序无法编译 声明如下:

typedef struct __WIZCHIP
{
uint16_t if_mode; //<主机接口模式
uint8_t id[6]; //<@b WIZCHIP ID、如@b 5100、@b 5200、@b 5500等。
/**
*关键段回调函数集。
*/
struct _cris
{
void (*_enter)(void); ///<曲面输入
void (*_exit)(void); ///<初始分区退出
}CRIS;
/**
*@ref \_WIZCHIP_的集合选择控制回调 func。
*/
struct _CS
{
void (*选择)(void); ///<@ref \_WIZCHIP_已选择
void (*取消选择)(void); //<@ref \_WIZCHIP_已取消选择
CS;
/**
*接口 IO 回调函数集。
*/
union _if
{
/**
*表示总线接口 IO
*
//M20156501:修改与 W5300集成的函数名
//struct
//{
// uint8_t (*读取字节)(uint32_t AddrSel);
// void (*_WRITE_BYTE)(uint32_t AddrSel、uint8_t WB);
//总线;
结构
{
iodata_t (*读取数据)(uint32_t AddrSel);
无效 (*_WRITE_DATA)(uint32_t AddrSel、iodata_t WB);
总线;

/**
*用于 SPI 接口 IO
*
结构
{
uint8_t (*读取字节)(void);
void (*写入字节)(uint8_t WB);
void (*读取突发)(uint8_t* pBuf、uint16_t len);
void (*_WRITE_BURST)(uint8_t* pBuf、uint16_t len);
} SPI;
//待添加
//
}if;
}_WIZCHIP; 

在“  }CS;”行上,出现以下错误:

170这里不允许使用函数类型
18期待一个“)”
#80需要类型说明符

 

有人知道如何解决这个问题吗?

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

    很遗憾、我无法重现问题。  我不得不猜测一些细节、我确信我猜错了。  请提供一个测试用例、如文章 如何提交编译器测试用例中所述。  

    谢谢、此致、

    乔治

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

    我已附加预处理的源文件、构建日志 和项目。 我使用的是 TI v16.9.3.LTS 编译器。

    我希望您能提供一个解决方案。 谢谢!

    e2e.ti.com/.../wizchip_5F00_conf.pp.txt

    e2e.ti.com/.../2867.Build-log.txt

    e2e.ti.com/.../0310.test.zip

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

    我明白发生了什么。  我无法告诉您解决它的最佳方法。  我必须使用该项目才能找到它。

    构建源文件 ExtensionManager.c 时会发生此问题。  其他文件也可能会发生这种情况。  但这是我关注的问题。

    此文件包括许多其他文件。  通过使用--preproc_includes 选项,我可以看到这一点...

    C:/Userdata/mytemp/wizchip_test/Extensions/ExtensionManager.h
    C:/ti/simplelink_msp432_sdk_1_30_00_40/source/ti/devices/msp432p4xx/driverlib/driverlib.h
    C:/ti/simplelink_msp432_sdk_1_30_00_40/source/ti/devices/msp432p4xx/driverlib/adc14.h
    C:/ti_ccs62/ccsv6/tools/compiler/ti-cgt-arm_16.9.3.sps/include/stdint.h
    C:/ti/simplelink_msp432_sdk_1_30_00_40/source/ti/devices/msp432p4xx/inc/msp.h
    C:\ti\simplelink_msp432_sdk_1_30_00_40\source\ti\devices\msp432p4xx\inc\msp432p401r.h 

    这只是前几行。  稍后将显示...

    C:\UserData\mytemp\wizchip_test\Extensions\./W5500以太网芯片/WIZ5500.h
    C:/Userdata/mytemp/wizchip_test/W5500以太网芯片/ethernet/wizchip_conf.h
    

    文件 msp432p401r.h 具有此源代码行...

    #define CS ((CS_Type *) CS_BASE) 

    文件 wizchip_conf.h 将在稍后处理。  它具有这些源代码行...

    struct _CS
    {
    void (*选择)(void); ///<@ref \_WIZCHIP_已选择
    void (*取消选择)(void); ///<@ref \_WIZCHIP_
    已取消选择 CS; 

    由于#define CS,最后一个源代码行扩展至...

    }((CS_Type *)(((uint32_t) 0x40000000)+0x00010400); 

    这不是合法的 C 代码。  

    我通过使用选项--gen_preprocessor_listing 创建.rl 文件找到了所有这些内容。  此文件显示预处理前后发生的所有细节。  您可以在 ARM 编译器手册中阅读我在这篇文章中提到的所有选项。

    虽然我可以考虑可能的解决方案、但我不确定哪种解决方案最适合您的情况。  这需要了解我没有的 SimpleLink 头文件。  我建议您在 MSP 器件论坛中开始新的主题。 或者、如果您愿意、我可以将此主题移至该论坛。

    谢谢、此致、

    乔治

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

    请将主题移至其他论坛。  一种解决方案是(重构)从 WIZnet 文件重命名结构。 我 已将 CS 重命名为 CSWiz (及其所有引用)、 它起作用。