.H

H File

C/C++ Header File
Ask a question
QUICK ANSWER

A .h file is a C/C++ header file - plain-text source code that holds function prototypes, type definitions, constants, and macros shared across a program. You cannot run it; open it in any text or code editor such as VS Code or Notepad++. It is just text and safe to view, but code from untrusted projects should only be compiled in a safe environment.

Developer: N/A (C/C++ language convention; ISO/IEC standards) Category: Developer Files Open standard MIME: text/x-c
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 31, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the H file format?

.h files are created when working with C, C++ or Objective-C languages.

Contents of .h files

Files with the .h extension contain function declarations or macros, and can hold such data as:

  • variable and constant declarations,
  • struct, enum, and type definitions,
  • #include references to other header files

In practice, .h files are used to hold shared declarations - code that is referenced frequently across multiple .c and .cpp source files. This allows for better source code legibility and programmer efficiency. Functions and macros defined in .h files make them reusable across projects and facilitate code sharing. This also makes it easier to update the code, as the interface is stored in a single, well-known place.

How are .h files used?

Storing shared declarations in .h files makes them easier to access and add to project source code. During compilation, the C preprocessor expands each #include directive, copying the header's contents into the translation unit before the compiler continues. System headers such as <stdio.h> or <vector> ship with the compiler and do not need to be distributed with your project; project-specific .h files, however, are part of the source tree and travel with it. Many C++ projects also use .hpp files to distinguish C++-only headers from plain-C .h headers, though both rely on the same #include mechanism.

Security & safety

RISK: LOW

A .h header is plain-text source code and does not execute by itself, so opening or reading one in an editor is safe. The real-world caution is about COMPILING, not the file format: header (and source) code from an untrusted project can contain malicious logic that only runs once you build and execute the program, so review and build unknown C/C++ code only in a sandbox/VM and from sources you trust. There is no risk in simply viewing the text. (Headers can also #include system files and define macros that change how dependent code compiles - relevant to developers, not a security threat from the file alone.)

Format details

in a nutshell
FULL NAMEC/C++ Header File
DEVELOPERN/A (C/C++ language convention; ISO/IEC standards)since 1972 (C language; #include header convention from early C)
MIME TYPEtext/x-c
TYPEPlain-text source-code header (text)
STANDARDOpen · royalty-free
This extension is also used by…
  • Objective-C / Objective-C++ header - Apple's Objective-C also uses .h headers (e.g. declaring @interface classes), opened the same way in Xcode/text editors.
  • ch / various app data - A handful of niche programs (and old game/data tools) reuse .h for non-source data; identify by the file's contents, not the extension.

Programs that open H files

Windows4 apps
Microsoft Visual Studio Freemium Full IDE (free Community edition); open the project or the .h to edit, navigate definitions and build the C/C++ code.
Windows Notepad Built-in Built-in plain-text editor - opens the .h to read it (no syntax highlighting). Fine for a quick look.
Notepad Open-source Free editor; open the .h to read/edit with C/C++ syntax highlighting.
Visual Studio Code Free Free, lightweight code editor; open the .h for syntax highlighting, navigation and (with the C/C++ extension) IntelliSense.
macOS3 apps
TextEdit Built-in Built-in editor; open the .h as plain text (use Format > Make Plain Text). No highlighting.
Apple Xcode Free Apple's IDE (free on the Mac App Store); open the .h within a project to edit C/C++/Objective-C headers.
Visual Studio Code Free Free cross-platform editor; open the .h to read/edit with C/C++ highlighting and tooling.
Linux4 apps
gedit Open-source GNOME's simple text editor; open the .h to view/edit with highlighting.
GNU Emacs Open-source Open the .h in Emacs (cc-mode) to read/edit with full C/C++ support.
Visual Studio Code Free Free code editor for Linux; open the .h for highlighting and navigation.
Vim / Neovim Open-source vim file.h to edit in the terminal with C/C++ syntax highlighting.

Technical details

deep spec
File typePlain-text source-code header
MIME typetext/x-c
File signature (magic bytes)None - plain text, identified by extension and content
Typical opening constructInclude guard (`#ifndef NAME_H` / `#define NAME_H`) or `#pragma once` to prevent multiple inclusion
Preprocessor roleExpanded inline by the C preprocessor before compilation; `.h` files are not compiled directly
Include syntaxSystem headers use angle brackets (e.g., `<stdio.h>`); project headers use double quotes (e.g., `"mylib.h"`)
Typical contentsFunction declarations, macro definitions, struct and enum definitions, typedef aliases, and (in C++) class declarations
Related extensions`.c`, `.cpp`, `.hpp`, `.hxx`, `.hh`, `.cc`, `.cxx`
C++ linkageC headers included in C++ code are often wrapped in `extern "C" { }` blocks to prevent name mangling
Character encodingASCII (historical norm); UTF-8 widely accepted by modern compilers for identifiers and comments
Multiple-inclusion protectionInclude guards or `#pragma once` ensure the same header is processed only once per translation unit
Standard C library headersFollow the `<name.h>` convention, e.g., `<stdio.h>`, `<stdlib.h>`, `<string.h>`
Template definitions (C++)Function and class templates must be fully defined in header files since they are instantiated at compile time
Released1972 (C language; #include header convention from early C)
Open standardYes · royalty-free
Specificationen.cppreference.com

H conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with H files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about H files.

Frequently asked questions

How do I open a .h file?
Open it in any text or code editor - the free VS Code, Notepad++ (Windows), Vim/Emacs/gedit (Linux), or Xcode (Mac). Even Windows Notepad or macOS TextEdit will show the text. It's plain-text source code.
What is a .h file?
It's a C/C++ header file: plain-text source containing declarations (function prototypes, types, constants, macros) that other source files share via #include. It's part of a program's code, not a document or program you run.
What's the difference between a .h and a .c (or .cpp) file?
The header (.h) holds declarations and interfaces; the .c/.cpp holds the actual implementation (the code that does the work). Source files #include the header so they all agree on the same definitions.
Can I run or open a .h file by double-clicking it?
No - a header does nothing on its own. It only matters when a C/C++ compiler builds it together with the source files that #include it. Double-clicking just tries to open it in a text editor.
Why do I get 'fatal error: xxx.h: No such file or directory'?
The compiler can't find a header your code #includes - the file is missing or its folder isn't on the include path. Install the required library/SDK, or add its include directory to your build settings.
What is the difference between .h and .hpp?
Both are headers. .h is the traditional C (and shared C/C++) extension; .hpp/.hxx/.hh are conventions some projects use to mark a header as C++-only. Compilers treat them the same; the extension is a style choice.

References

1cppreference - C++ standard library headersen.cppreference.com
2cppreference - Source file inclusion (#include)en.cppreference.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.MDMarkdown Document
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.EXEWindows Executable (Portable Executable)
9.DATProgram Data File (generic)
10.TXTPlain Text File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z