English 中文(简体)
Consistenty header file names between C++ libraries
原标题:

In my project I use two libraries, v8 and boost. Boost uses the .hpp extension for its headers, while v8 uses the .h extension for its headers.

In the end of day, my source code starts like that:

#include "v8.h"
#include "boost/filesystem.hpp"
...

In other question I asked about this subject, the general answer was that it is okay, but I just should be consistent between names.

This code compiles well, but, coding styles/standards - is it okay? Is there any solution for this problem (like changing all .hpp to .h automatically somehow?)

Thanks. And sorry for those stupid questions.

最佳回答

Don t worry about the inconsistency, it doesn t matter. Too much time is often spent obsessing about such details, and everyone is guilty of it.

Just be consistent with your own coding standards.

You ll eventually use some 3rd party library or several that use different conventions than you. There s nothing you can do about it, and often 2 of those libraries you use will be conflicting with your standards and with each other. That s not only for include extensions, but also for naming convetions like function_that_does_something vs FunctionThatDoesSomthing .It s fine.

I would definitely strongly advice against trying to change someone else s library to fit into your coding standard. I.e. for example renaming boost .hpp to .h. This is a bad idea and when you want to upgrade to newer versions of the library it will be a nightmare.

Spend your time solving the problem you re solving in a more elegant way rather than worrying about details like this.

问题回答

It s fine. Coding standards don t really come into it since you have to go with what you re given. If the v8 people only provide .h and the boost people only provide .hpp then, short of copying one set of files to the other choice or providing your own wrapper header files, you have few options.

Both of those option have their downsides for what is really dubious benefits, so I wouldn t concern yourself with the fact that you have to include two different file extensions.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签