Reputation:
I have a custom header file ("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
In one of the source files I have:
#include "../inc/strings.h"
In the code when I use:
sdkShow (LINE3, 0, POS_STR_TITLE_OPERATIONS );
I get error:
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
Any ideas why?
Upvotes: 0
Views: 1314
Reputation: 6070
the guard should always reflect the name of the header-file to guard, so it should be "strings_H_" and "sdkGlobal_H_"
it is intended for greater products where header-files have dependencies of their own. for example "a.h" needs "length.h" and "b.h" needs "length.h" also, you guard "length.h" to be evaluated once.
Upvotes: 1
Reputation: 22890
It seems administration_H_
is already defined.So rather than
#if !defined administration_H_
#define administration_H_
#define POS_STR_TITLE_OPERATIONS "somestr"
#endif
you intended
#if !defined administration_H_
#define administration_H_
#endif
#if !defined POS_STR_TITLE_OPERATIONS
#define POS_STR_TITLE_OPERATIONS "somestr"
#endif
Upvotes: 1