Xcode 7 and .hpp files

Hi all, I’m using xcode 7 (got upgraded automatically) and now when I go to make a new file for a class xcode makes a .cpp and a .hpp not .h.
After applying the fix pinned at the top of the forum my old projects run OK with the previous .h files but it would be good to know what .hpp means in relation to OF.

thanks

PMc

Hi petermc,

I’m in the same situation: Xcode got upgraded to v7, applied fix, and everything worked as expected again, but C++ header files now use the .hpp extension.

Using .hpp instead of .h doesn’t make any difference in general terms, and OF handles them properly. It’s a matter of naming conventions: officially, C headers should be some_class.h while C++ headers should be some_class.hpp. But both are essentially the same when using C++.

Don’t know how to go back to .h in Xcode 7 though.

The behavior can be changed quite easily by renaming the file ___FILEBASENAME___.hpp to ___FILEBASENAME___.h in this folder:

/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/C++\ File.xctemplate/WithHeader

Also you have to change all occurences of “hpp” to “h” in both template files in this folder.

When I try to change hpp to h in “FILEBASENAME.hpp” this file, I couldn’t because of locking.

What does this mean?

Yes, you need admin privileges to modify the file.

That means that you should change “hpp” everywhere to “h”. For example

#include "___FILEBASENAME___.hpp"

to

#include "___FILEBASENAME___.h"
1 Like

I made a template that automatically adds "ofMain.h" to the file as well. You can download it at https://app.box.com/s/cogczkew2zl31uf7hwojoydy84paxmt0.

Just unzip and place the folder into /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/. You should then see a file named Open Frameworks File under OS X -> Source.

8 Likes

Works great, robksawyer. Thanks for posting!