3

私の avrstudio4 プロジェクトでは、次のエラーが発生しました。

../Indication.c:95:15: error: static declaration of 'menu_boot' follows non-static declaration

main.c#include "indication.h" と入力します

indicator.h は、 indication.cのヘッダー ファイルであり、関数は次のように定義されています

unsigned char menu_boot(unsigned char index, unsigned char *menu1) 
__attribute__((section(".core")));

私は持っているindication.c

#include "indication.h"
...
unsigned char menu_boot(unsigned char index, unsigned char *menu1)

私は何をすべきか?

4

1 に答える 1

2

額面どおりに解釈すると、このエラー メッセージは、ファイルの 95 行目../Indication.c(説明したファイルと同じファイルである場合もそうでない場合もあります) に、次のようindication.cな静的宣言があることを意味します。menu_boot

static unsigned char menu_boot(unsigned char index, unsigned char *menu1);

または、次のような静的定義:

static unsigned char menu_boot(unsigned char index, unsigned char *menu1)
{
    ...
}

ファイル内の次のコードを検討してくださいxx.c

extern unsigned char function(int abc);

static unsigned char function(int abc);

static unsigned char function(int abc)
{
    return abc & 0xFF;
}

GCC 4.1.2 (RHEL 5 上) でコンパイルすると、コンパイラは次のように表示します。

$ gcc -c xx.c
xx.c:3: error: static declaration of ‘function’ follows non-static declaration
xx.c:1: error: previous declaration of ‘function’ was here
$

3 行目をコメントアウトすると、コンパイラは次のように言います。

$ gcc -c xx.c
xx.c:6: error: static declaration of ‘function’ follows non-static declaration
xx.c:1: error: previous declaration of ‘function’ was here
$

メッセージは同じですが、以前の宣言があった場所に関する情報が含まれています。この場合、同じソース ファイルにあります。宣言が翻訳単位に含まれる別のソース ファイル (通常はヘッダー) にある場合、その別のファイルを識別します。

于 2012-09-25T13:41:44.580 に答える