I just started using XCode to do basic C++ programming. I have noticed something strange.

When Im working on a C++ project, and want to add a new C++ source file, the automatic generated file is formated as a C file, even though its extention is .cpp.

Im using Xcode 6.1.1. I was a member of the Mac OSX public beta program, but I think I use the released version of Xcode.

Can anybody reproduce this bug, or is it just my system that got this bug? If so, how could I fix it?

This is what a typical automatic created header file look like:

//  testfunk.h
//  Test
//  Created by Jørgen Rørvik on 16.01.15.
//  Copyright (c) 2015 Jørgen Rørvik. All rights reserved.

#ifndef __Test__testfunk__
#define __Test__testfunk__

#include <stdio.h>

#endif /* defined(__Test__testfunk__) */
  • How does the format of a C and c++ differ?
    – mmmmmm
    Jan 23, 2015 at 10:10
  • I would expect a C++ project to use <iostream> instead of stdio.h which is a C library. When I start a new project, the main.cpp includes <iostream>, so I think this is a bug.
    – SM411
    Jan 23, 2015 at 10:15
  • That is not formatting but creation of a new file - you need to rewrite the question to say what is the problem - also search for Xcode templates as these are what set things
    – mmmmmm
    Jan 23, 2015 at 10:48

1 Answer 1


The Xcode template for C++ files does have #include <stdio.h>. To change this you have to create a template of your own - See several Stack Overflow questions here or here

  • This will solve my problem, but I still think that it is a bug. Do you agree?
    – SM411
    Jan 23, 2015 at 10:53
  • Yes but I would note I gave up C++ programming in Xcode as it does not really support it e.g. try namespaces and code completion - for C and Objective C it is good
    – mmmmmm
    Jan 23, 2015 at 13:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .