I’m learning C and hope someone can explain what’s the logic of using #ifndef?
I also find many C programs I looked, people seems following a convention using the filename following the #ifndef, #define and #endif. Is there any rule or tip on how to choose this name?
#ifndef BITSTREAM_H
#define BITSTREAM_H
#include <stdio.h>
#include <stdint.h>
/*Some functions*/
#endif
The term for what you’re looking for is Preprocessor Directives.
#ifndefdoesn’t need to be followed by a filename, for example it’s common to see#ifdef WINDOWSor#ifndef WINDOWS, etc.