2013-06-21 24 views
0

我無法識別我犯的錯誤,並且不知道如何google解決方案。我收到以下錯誤:AVR-GCC - 包含頭文件的枚舉錯誤

#ifndef DEBUG_MODE_HEADER 
#define DEBUG_MODE_HEADER 

#include "uart.h" 
#include <stdbool.h> 
#include <avr/pgmspace.h> 
#include "buttons.h" 

bool DebugModeEnabled = false; 

void SetDebugMode(); 
void AnnounceDebugMode(bool State); 
void DebugAnnounceLEDState(); 
void DebugAnnounceButtonState(ButtonFlags Button); 

#endif 

和:

In file included from buttons.h:8, 
       from buttons.c:1: 
debug_mode.h:14: error: expected ')' before 'Button' 

我有一個枚舉在buttons.h

#ifndef BUTTONS_HEADER 
#define BUTTONS_HEADER 

#include <avr/io.h> 
#include <stdbool.h> 
#include <util/delay.h> 
#include "uart.h" 
#include "debug_mode.h" 

typedef enum { 
    NO_BUTTON, 
    BUTTON1, 
    BUTTON2, 
    BUTTON3, 
    BUTTON4, 
    BUTTON5, 
    BUTTON6 
} 
ButtonFlags; 

void CheckButtons(); 
void SetButtonFlag(); 
void ProcessButtons(); 

#endif 

我包括它在另一個頭debug_mode.h聲明debug_mode.c:

#include "debug_mode.h" 

void DebugAnnounceButtonState(ButtonFlags Button) 
{ 
    SendUARTString_P(DEBUGMODE_BUTTON_PRESSED_MSG); 
    switch (Button) 
    { 
     case 1: SendUARTString_P(DEBUGMODE_BUTTON1_MSG); break; 
     default: break; 
    } 
} 

A倪援助

+0

我發現一個包含循環。你包括buttons.h其中包括debug_mode.h,其中包括button.h ... –

回答

2

您的標題buttons.h和debug_mode.h包括對方。您將需要以這種方式重構代碼,以消除這種循環依賴。

+0

謝謝重構。知道循環依賴,但由於某種原因,並不認爲它可能是罪魁禍首。 – Talib