This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

multiple REG51.H includes

Hello, I'm new in KEIL sw. As I can see I can include REG51.h file in only one C or ASM file in the whole project... is that possible?

Best regards,
Branislava

  • No, that's quite definitely an incorrect observation. You may have to be careful not to #include it more than once in a single translation unit (i.e. one source file), but other than that, there's no such limitation.

    If this doesn't agree with your observation, please describe those observations in more detail.

  • As Hans pointed out, you can include the REG51.H in multiple files. Did you add any #defines or modify the .h file in any other manner?

  • In a "normal" 'C' project, you would expect to find things like stdio.h included in many places throughout the Project; similarly, in a C51 project, you would expect to find many (most?) of the files including the appropriate version of reg51.h.

    Like stdio.h, reg51.h simply provides information about the external system - this is the purpose of header files.

    Where it all goes wrong is when people put variable or function definitions in headers, so that the header actually starts consuming system resources.
    Variables and functions must be defined in exactly one Source ('C' or ASM) or Library module; external declarations may then be placed in header file(s) to be included in as many modules as required.

  • Sorry, it was my mistake. I have overlapped some SFR defines.