Why do they write "ifndef file_h at the beginning of the file



  • What situations could the definition be useful in that way?

    #ifndef __IMAGE_H__
    #define __IMAGE_H__
    

    ////////////////////

    #endif



  • These directives are designed to protect against multiple inclusion when there is a complex hierarchy of the files involved - if such a file has already been inserted sometime sooner - then so __IMAGE_H__ It's gonna be announced, which means, #define will be missed, along with all the announcements before #endif

    Some compilators have similar effects. #pragmae.g.

    #pragma once
    

    But the version is the most universal.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2