We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I have two c source files in my project, and they both need include hardware.h(register define) file. I try to include the .h file to both C file but the compilter says the memory overlap. I choice include .h file to the main C file ,the compiliter says another c file's register not define. How to avoid it , thanks a lot.
Still not quite right: do not put the _at_ in the header file - that just goes in the definition; only name & type are required in the declaration As I've said before, if you #include the header in the 'C' file, it will give you the advantage of allowing the compiler to warn you if there's any mismatch:
//My.c #include "my.h" // allows the compiler to "see" both declarations & definitions // and thus to report any mismatch! unsigned char xdata A_register _at_ 0x0010; // A message will be given if this definition // does not match the preceding declaration in // the header! unsinged char xdata B_register _at_ 0x0020;
Since we're already using the nonportable "_at_" language extension, we'll let the C++ and C99 "//" commenting style slide on by without any points deduction ;-)