简体   繁体   中英

facing error “type qualifier specified more than once” with c++ compiler

i have header file as follows

**something.h**

#ifdef __cplusplus
extern "C" {
#endif
blah
blah
extern CONST oMenu_t const menu[];
blah
blah
#ifdef __cplusplus
}
#endif

though i have used appropriate(i suppose) extern "C" still facing error "type qualifier specified more than once" while compiling with c++ compiler.. help please

multiple const is not needed you may use:

extern oMenu_t const menu[];

in your .h file. However, you must have something like below in one .c file (define only once, declare as many times, as used in .h)

oMenu_t const menu[] = {....}; // appropriate initializer

Add

   #ifndef __FILENAME_HEADER_FILE
   #define __FILENAME_HEADER_FILE

your existing head file goes here...

    #endif // __FILENAME_HEADER_FILE

around your header file, this means you can include the .H many times but the compiler only sees it once.

FYI: Replace FILENAME with the name of your filename, the #define this needs to be different in each header file you use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM