Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
This checks if ALWAYS_H is defined , if it not then it is defined and the code that followed included, else the code is skipped
there is a #endif missing at the end
Usually the name used in the define is similar to the header file, for example for lcd.c you use _LCD_H.
The name used can be anything (NEVER_H or SOMETIMES_H), it doesn't make a difference in the operation of the code, it is just easier to understand it if it is similar to the header name.
If you don't define this:
Let's suppose that something in MyDefs.h is used at more than one place.
The compiler finds the item in MyDefs.h. Then in another part of the program,
it finds again the same item, and thinks it is declared twice and complain.
By using #ifndef _MY_DEFS_H_ at the beginning of MyDefs.h, the compiler will
read MyDefs.h a first time (since _MY_DEFS_H_ is not yet defined). But the next
time it tries to read it, it will just skip it since this time it has already been read
and _MY_DEFS_H_ is defined.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.