Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between hpp and hxx?

Tags:

c++

for gcc they should be the same, right? which one of them is more popular , i am now preparing a project from scratch and i would like to pick one among these 2.

thanks

like image 531
James Bond Avatar asked Dec 07 '09 20:12

James Bond


People also ask

Should I use HPP or CPP?

You should use the . hpp extension if you're working with C++ and you should use . h for C or mixing C and C++. Save this answer.

Is HPP same as H file?

h is more widely used for header files than . hpp when, . h refers to C header and . hpp refers C++ header.

What are HPP files for?

HPP files are a particular kind of developer source code file. They are so-called header files that contain source code written in C++, a programming language. The HPP file can contain variables, constants and various kinds of data types. Using #include, HPP files can be inserted into other source code files like CPP.

What are CXX and HXX files?

extensions: .hxx - this is the user header file to be included by your C++ code. .cxx - this is the actual C++ implementation code compiled into the. OpenCASCADE library.


2 Answers

In C++, the file extension doesn't actually matter. The use of .h, .hpp, .hxx, or no file extension are all by convention.

The standard library uses no file extension for its header files. Many projects, including Boost, use .hpp. Many projects use .h. Just pick one and be consistent in your project.

like image 155
James McNellis Avatar answered Oct 13 '22 00:10

James McNellis


I propose that we re-open this discussion, in view of a recent discovery that I made. For the last 9 years, I have used the following naming convention for the source files in my C and C++ projects.

  • C = Straight C source code, containing one or more related entry points
  • CPP = C++ source code, containing one or more related entry points
  • H = Declaration of functions, macros, structures, typedefs, etc.
  • INL = Inline (function bodies) that are the bodies of two or more functions whose main definition file is a C or CPP file, into which they are incorporated by #include

An example of these common function bodies, MyStringFunctionA, the ANSI implementation, is defined in MyStringFunctionA.cpp, while MyStringFunctionW, the Unicode (wide character) implementation, is defined in MyStringFunctionW.cpp. MyStringFunctionA.cpp and MyStringFunctionW.cpp contain the prototype, opening and closing brackets, and headers, subject to UNICODE for the wide character version. The function body is defined in the INI file, which is #included inline, within the function definition block.

Combined with generic TCHAR mappings, this approach greatly simplifies maintaining Unicode and ANSI versions, both of which remain in active use.

This naming convention worked great with Visual Studio 6. However, when I began migrating my code base to Visual Studio 2013, I discovered an annoying change that was initially confusing. Although everything compiled cleanly, when one of my INL files was open in the code editor, I would see dozens of Intellisense "errors" listed in the Errors window. I quoted the term "errors" because they are not true errors; they vanish when the INL file is closed, and the C and CPP files into which the iNL is pulled compile without errors, link, and run correctly.

like image 24
David A. Gray Avatar answered Oct 12 '22 23:10

David A. Gray