struct.h:
#ifndef _STRUCT_H #define _STRUCT_H int i; #endif
#include "struct.h" void main(void) { i = 1; }
"no error if compiled in C compiler." Well, of course there isn't: you can only get Linker errors from the Linker!! See my reply here: http://www.keil.com/forum/docs/thread1812.asp Your file struct.h contains a definition of i; presumably you are also #includeing it in another 'C' source file (struct.c?) so that file will also contain a definition of i - presto! multiple definitions! You need to define i in one file only (eg, main.c) and then just have an extern declaration in your header file. BTW: 'i' is a particularly bad name for a global variable!
I think the two statements don't do any work as they do in C compiler in struct.h:
#ifndef #define
"I think the two statements don't do any work as they do in C compiler" Pardon? I don't understand what you're trying to say! Those lines are a standard 'C' coding practice known as an Include Guard - their purpose is to prevent any problems if you (accidentally) #include the same file twice.
There aren't those two lines in any header files in INC directory of KEIL why?
View all questions in Keil forum