Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Xcode to recognise C++ header files without the '.h' extension (OpenSceneGraph)

OpenSceneGraph uses header files without the '.h' extension. Is there a way of getting Xcode to recognise the syntax as C++ and therefore allow me to have highlighting and jumping to definitions etc?

Eg: No highlighting:

enter image description here

like image 259
brendanzab Avatar asked May 04 '12 01:05

brendanzab


People also ask

What is the file extension for C header files?

A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that comes with your compiler.

How do I open a header file in Xcode?

Holding the Command key, click the import/include statement to view the header. Also, you can Command-click on a symbol to jump to the header file that defines it.

Where does cpp look for header files?

For C++ programs, it will also look in /usr/include/g++-v3, first.


1 Answers

Yes. Toggle the right panel (the rightmost icon of the "View" section of the toolbar, arrow 1 in the screenshot) with your file selected. Select the document tab in the panel (arrow 2), then find "File Type" under "Identity and Type" (arrow 3). Choose "C++ header" in the dropdown list.

Graphical version of the previous explanations

You will need to reopen the file for the syntax coloring to kick in.

like image 122
zneak Avatar answered Oct 06 '22 04:10

zneak