why STL header files have no extension?

前端 未结 1 1273
梦毁少年i
梦毁少年i 2021-02-19 12:55

I got this basic doubt. The STL header doesn\'t have .h extension.

#include 
#include 

Is there is any s

1条回答
  •  囚心锁ツ
    2021-02-19 13:54

    • The #include directive doesn't discriminate file types (it's just a glorified copy-paste operation) - no automatic adding of .h is happening.
    • C++ standard header files are provided without the .h extension
    • Sometimes backward compatibility header files are provided by the vendor with the same name with the .h extension added

    It all has to do with namespaces. The .h counterparts for C++ standard headers usually #includes the proper C++ standard header (without .h extension) and then issues a bunch of using (something like this):

    FILE: iostream.h

    #include 
    
    using std::iostream;
    using std::ostream;
    using std::ios;
    ...
    

    whereas the headerfile without the .h extension does not pollute the namespace with all the defined classes and types.

    0 讨论(0)
提交回复
热议问题