This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

identifier is not defined

Hi,

I am trying to use HAL driver for STM32L053C8 discovery board.
In DMA.h I defined:

typedef struct
{
  DMA_Channel_TypeDef    *Instance;          /*!< Register base address                  */

  DMA_InitTypeDef       Init;           /*!< DMA communication parameters           */

  __IO DMA_StateTypeDef  State;        /*!< DMA transfer state                     */

  void                  *Parent;           /*!< Parent object state                    */

  //void                  (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma);     /*!< DMA transfer complete callback         */

  //void                  (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback    */

  //void                  (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma);    /*!< DMA transfer error callback            */

}DMA_HandleTypeDef;

then in ADC.h I include that DMA.h file but after compilation, the compiler reports:
..\Inc\ADC.h(127): error: #20: identifier "DMA_HandleTypeDef" is undefined DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
..\Src\DMA.c: 0 warnings, 1 error

Actually there is no red cross on the right of DMA_HandleTypeDef in Keil uvision5 IDE in ADC.h file.

typedef struct __ADC_HandleTypeDef
{
  ADC_TypeDef                   *Instance;              /*!< Register base address */

  ADC_InitTypeDef               Init;                   /*!< ADC required parameters */

  DMA_HandleTypeDef             *DMA_Handle;            /*!< Pointer DMA Handler */

  __IO ADC_StateTypeDef                 State;                  /*!< ADC communication state */

  //__IO uint32_t                 ErrorCode;              /*!< ADC Error code */
}ADC_HandleTypeDef;


I dont know the reason why that happenes. Can anyone help me? Thank you.

Parents
  • It seems that ADC is compiled ealier than DMA.

    No, that is not the reason.

    The problem is that DMA.c has an #include of ADC.h in it, but no (fully working) #include of DMA.h before that. As ADC.h uses a type from DMA.h, it should normally #include "DMA.h" to make sure that type is known. It doesn't, and that's why you get that error message.

    Forget about search paths, or the order of files in the project. You need to worry about the order of #includes in your source, and in the #include's files themselves.

Reply
  • It seems that ADC is compiled ealier than DMA.

    No, that is not the reason.

    The problem is that DMA.c has an #include of ADC.h in it, but no (fully working) #include of DMA.h before that. As ADC.h uses a type from DMA.h, it should normally #include "DMA.h" to make sure that type is known. It doesn't, and that's why you get that error message.

    Forget about search paths, or the order of files in the project. You need to worry about the order of #includes in your source, and in the #include's files themselves.

Children