0

カスタム ヘッダー ファイル ( "strings.h")があります。

#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */
#include "sdkGlobal.h"

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#if !defined administration_H_
#define administration_H_

#define POS_STR_TITLE_OPERATIONS "somestr"

#endif

私が持っているソースファイルの1つに:

#include "../inc/strings.h"

私が使用するときのコードで:

    sdkShow (LINE3, 0, POS_STR_TITLE_OPERATIONS );

エラーが発生します:

src/main.c: In function 'postMainMenu':
src/main.c:190: error: 'POS_STR_TITLE_OPERATIONS ' undeclared (first use in this function)
src/main.c:190: error: (Each undeclared identifier is reported only once
src/main.c:190: error: for each function it appears in.)
make[1]: *** [src/main.o] Error 1
make: *** [all] Error 2

理由はありますか?

4

2 に答える 2

1

administration_H_すでに定義されているようです。

#if !defined administration_H_
#define administration_H_

#define POS_STR_TITLE_OPERATIONS "somestr"

#endif

あなたが意図した

#if !defined administration_H_
#define administration_H_
#endif

#if !defined POS_STR_TITLE_OPERATIONS
#define POS_STR_TITLE_OPERATIONS "somestr"
#endif
于 2014-01-08T11:28:44.327 に答える
1

ガードは常にガードするヘッダー ファイルの名前を反映する必要があるため、"strings_H_" および "sdkGlobal_H_" にする必要があります。

これは、ヘッダー ファイルが独自の依存関係を持つより大きな製品を対象としています。たとえば、「ah」には「length.h」が必要で、「bh」には「length.h」が必要です。また、「length.h」が一度評価されるようにガードします。

于 2014-01-08T11:52:02.207 に答える