g ++说函数的参数太多了,但函数匹配原型

时间:2013-06-21 21:33:37

标签: c++ compiler-errors g++ cross-compiling

我试图在STM32F4上交叉编译一些代码。我使用以下编译命令:

CFLAGS="$WARNINGS -g -O0 -D USE_STDPERIPH_DRIVER -DSTM32F40XX -fomit-frame-pointer -fno-strict-aliasing -fno-dwarf2-cfi-asm -mcpu=cortex-m4 -mthumb -mhard-float -nostdlib"    

arm-none-eabi-g++  -c $CFLAGS -I$SOURCE_PATH/application -I$SOURCE_PATH/library/CMSIS/Include -I$SOURCE_PATH/library/CMSIS/Device/ST/STM32F4xx/Include -I$SOURCE_PATH/library/STM32F4xx_StdPeriph_Driver/inc *.c *.cpp

我收到以下错误:

DMAManager.cpp: In constructor 'STMicroelectronics::DMAManager::DMAManager(unsigned char*, size_t)':
DMAManager.cpp:10:16: error: 'IntializeLED' was not declared in this scope
DMAManager.cpp: In member function 'void STMicroelectronics::DMAManager::InitializeSPI()':
DMAManager.cpp:93:33: error: too many arguments to function 'void SPI_Init(SPI_TypeDef*)'
In file included from ../application/stm32f4xx_conf.h:59:0,
                 from ../library/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:7116,
                 from stm32f4_discovery.h:53,
                 from DMAManager.h:40:
../library/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h:501:6: note: declared here
DMAManager.cpp:96:23: error: too many arguments to function 'void SPI_Cmd(SPI_TypeDef*)'
In file included from ../application/stm32f4xx_conf.h:59:0,
                 from ../library/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:7116,
                 from stm32f4_discovery.h:53,
                 from DMAManager.h:40:
../library/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h:505:6: note: declared here
DMAManager.cpp: In member function 'void STMicroelectronics::DMAManager::InitializeDMA()':
DMAManager.cpp:156:49: error: too many arguments to function 'void SPI_I2S_DMACmd(SPI_TypeDef*)'
In file included from ../application/stm32f4xx_conf.h:59:0,
                 from ../library/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:7116,
                 from stm32f4_discovery.h:53,
                 from DMAManager.h:40:
../library/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h:526:6: note: declared here
DMAManager.cpp:159:49: error: too many arguments to function 'void SPI_I2S_DMACmd(SPI_TypeDef*)'
In file included from ../application/stm32f4xx_conf.h:59:0,
                 from ../library/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:7116,
                 from stm32f4_discovery.h:53,
                 from DMAManager.h:40:
../library/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h:526:6: note: declared here

有问题的代码段(为简洁起见):

        SPI_Init(SPI1, &SPI_InitStruct); 

        /* enable SPI1*/
        SPI_Cmd(SPI1, ENABLE); 

        /* Enable SPI DMA TX Requests */
        SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Tx, ENABLE);

        /* Enable SPI DMA RX Requests */
        SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Rx, ENABLE);

因此,显然编译器认为没有遵循这四个命令的函数原型。但是,相同的代码在gcc下工作正常。更重要的是,有问题的头文件没有像编译器那样定义函数。它们的原型与我使用它们完全一样。

更奇怪的是,我找不到任何定义,例如编译器在任何地方描述的定义。我使用-E -g3标志运行编译器以获得编译器看到的后预处理器文本的转储,并且在~2.2兆字节文本文件中没有任何地方存在这四个定义中的任何一个g ++我说我违反了。它们都被定义为我使用它们。

这是定义所有这些函数的.h文件:

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_SPI_H
#define __STM32F4xx_SPI_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"

....Many other #defines that are unrelated....

#define SPI_DMAReq_Tx                SPI_I2S_DMAReq_Tx
#define SPI_DMAReq_Rx                SPI_I2S_DMAReq_Rx
#define SPI_IT_TXE                   SPI_I2S_IT_TXE
#define SPI_IT_RXNE                  SPI_I2S_IT_RXNE
#define SPI_IT_ERR                   SPI_I2S_IT_ERR
#define SPI_IT_OVR                   SPI_I2S_IT_OVR
#define SPI_FLAG_RXNE                SPI_I2S_FLAG_RXNE
#define SPI_FLAG_TXE                 SPI_I2S_FLAG_TXE
#define SPI_FLAG_OVR                 SPI_I2S_FLAG_OVR
#define SPI_FLAG_BSY                 SPI_I2S_FLAG_BSY
#define SPI_DeInit                   SPI_I2S_DeInit
#define SPI_ITConfig                 SPI_I2S_ITConfig
#define SPI_DMACmd                   SPI_I2S_DMACmd
#define SPI_SendData                 SPI_I2S_SendData
#define SPI_ReceiveData              SPI_I2S_ReceiveData
#define SPI_GetFlagStatus            SPI_I2S_GetFlagStatus
#define SPI_ClearFlag                SPI_I2S_ClearFlag
#define SPI_GetITStatus              SPI_I2S_GetITStatus
#define SPI_ClearITPendingBit        SPI_I2S_ClearITPendingBit
/**
  * @}
  */

/**
  * @}
  */

/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ 

/*  Function used to set the SPI configuration to the default reset state *****/ 
void SPI_I2S_DeInit(SPI_TypeDef* SPIx);

/* Initialization and Configuration functions *********************************/
void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct);
void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct);
void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct);
void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct);
void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState);
void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize);
void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction);
void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
void SPI_TIModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState);

void I2S_FullDuplexConfig(SPI_TypeDef* I2Sxext, I2S_InitTypeDef* I2S_InitStruct);

/* Data transfers functions ***************************************************/ 
void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data);
uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx);

/* Hardware CRC Calculation functions *****************************************/
void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState);
void SPI_TransmitCRC(SPI_TypeDef* SPIx);
uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC);
uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx);

/* DMA transfers management functions *****************************************/
void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState);

/* Interrupts and flags management functions **********************************/
void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState);
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);

#ifdef __cplusplus
}
#endif

#endif /*__STM32F4xx_SPI_H */

0 个答案:

没有答案