.h
Low riskC / C++ header
A C or C++ header file. Declares types, function prototypes, and macros pulled into other sources via `#include`.
MIME types
- text/x-c
- text/x-chdr
Category
code
Aliases
.hpp / .hxx
What opens this file
- gcc / clang / MSVC
- VS Code + C/C++ extension
- CLion
How to open by OS
Windows
- MSVC, MinGW.
Mac
- clang (Xcode).
Linux
- gcc, clang.
Ios
- Remote build.
Android
- NDK.
Safety notes
- Headers don't usually execute code, but preprocessor macros can rewrite semantics in ways that are hard to notice.
Common mistakes
- Forgetting include guards (
#pragma onceor#ifndef) causes duplicate-definition errors. - Putting too much implementation in headers balloons compile time. Split declaration and definition.