views:

872

answers:

5

I am using g++ on Ubuntu with a C++ library whose header files all happen to end in .H instead of the traditional .h.

I'd rather not modify the include directory ... otherwise I would probably just create symbolic links to .h versions of the headers.

I am wondering if there is an easy way to automatically have g++ recognize that .H and .h files are the same so that I can write either header.h or header.H in my program? I've looked through the g++ man page, but it's pretty hard for me to tell if it supports some feature like this.

+2  A: 

I think this is an implementation detail of the Linux file system. While on Windows .h and .H files are effectively the same, on Linux you can have a traditional.h and a traditional.H in the same directory.

If I am understanding you correctly, you just need to specify the capital H in the files that include your headers.

Oliver N.
+3  A: 

The problem stems from the filesystem. Your filesystem is case sensitive and thus sees a difference between header.h and header.H. This isn't a g++ issue. Running on a case insensitive filesystem/OS you won't see this problem, as is the case when running g++ on a win32 system.

tallganglyguy
+7  A: 

.H is one way that C++ header files are named distinctly from C header files (also .hpp or .hxx). This only works in case sensitive OSs.

If the file has a .H, just #include <file.H>

crashmstr
+2  A: 

If you don't want to rename the header files or have your source #include .H files, you could create a set of .h files which just #include the corresponding .H file.

jon hanson
+2  A: 

I can't think of any easy way to get gcc to become case-insensitive, so you might have to grit your teeth and use an alternate solution, like

#include "foo.H"

...or create some symbolic links:

# create .h links to all .H files below the current dir
for basename in `find . -name *.H | sed 's/\(.*\)\..*/\1/'`; do
  ln -s $basename.H $basename.h
done

FYI, there's a recent thread on the gcc mailing list requesting case-insensitivity. The responses are mostly concerned with efficiency -- if you start asking the compiler to look for all versions of "foo.h" (e.g. "FOO.H", "Foo.H", "foo.H") then you'll be accessing the disk a lot more frequently. And who needs even longer build times? :)

Nate Kohl