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

can constants defined in a file be used in other file without defining ?

i have defined

#define key0  0x35 
in main file and now i want to use key0 in one of included file in this project
but on compilation i get error for this.
Does keil have any provision where i can use defined constants
of one file in other file without redefining them ?

Parents
  • "book to which i had reffered did not carry detail about this."

    In that case, it does not qualify as a "good" book on 'C' - this is fundamental stuff.

    "Is it neccessary that header file created by us should be kept in "inc" folder."

    No.
    As with any application trying to find a file, there are certain default locations where the compiler will look, and a certain order in which it will try the alternatives - or you can explicitly state the file's location by includinging a full or relative path.
    You need to read the Compiler Manual for details. For C51, see the INCDIR directive.

Reply
  • "book to which i had reffered did not carry detail about this."

    In that case, it does not qualify as a "good" book on 'C' - this is fundamental stuff.

    "Is it neccessary that header file created by us should be kept in "inc" folder."

    No.
    As with any application trying to find a file, there are certain default locations where the compiler will look, and a certain order in which it will try the alternatives - or you can explicitly state the file's location by includinging a full or relative path.
    You need to read the Compiler Manual for details. For C51, see the INCDIR directive.

Children
No data