XCode C++ Question (.tpp files)

new to the forum(My first posting).

I am working on a c++ project for school, and the teacher mandates that we use a .tpp file for our next program. I started out by just adding the .tpp file(named types.tpp), but it doesnt seem to pick up the syntax for c++ on it. How would I go about adding this file to my c++ project and still being able to incorporate all of the syntax rules and settings?

Bit new to the whole programming scene, so im not up to par on the jargon yet.

Thanks in advance

MacBook Pro 2.5 Core 2 Duo, Mac OS X (10.5.5)

Posted on Nov 30, 2008 5:09 PM

Reply
12 replies

Dec 1, 2008 10:57 AM in response to Sirjacksinurbox

First off, tell the teacher he's being a twit since .h files work just fine and it's only the most anal of annoying twits like the STLplus clowns who insist on inventing some distinction between implementation and definition of templates for no particularly useful reason in the world and to the immense inconvenience of people who actually use production tools none of which have a clue what on earth "tpp" might be, as you've seen in this thread already.

Second off, drop your C++ class and take up Objective-C so you can use a dynamic language where stupid compiler tricks like templates aren't necessary in the first place. Seriously. A handful of Cocoa projects later, you're going to be looking at your old C++ projects thinking "Why the @(#$&@&#!! did it ever make sense to have to write this kind of stupid @#($&@#$&!!!"

Okay, moving on to immediately practical recommendations now, what you should do is select your project target in the inspector, go to the 'Rules' tab and add a new rule for .tpp -- and contrary to Eric's instructions above, make it "sourcecode.cpp.h" not "sourcecode.cpp.cpp".

(That's the whole reason -- wait, let me scare quote that, "reason", since it's not a GOOD reason -- that some people want this .tpp extension to exist: it actually is an implementation file not a header file, so their uptight Sense Of Rightness is offended by using .h for it; however, since template implementations are compiled using header compilation rules, it is not correct to just rename them .cpp and be done with it. To avoid their little minds exploding from this cognitive dissonance, the only thing they can think of to do is to inconvenience those of us who just want to get work done by making up this new .tpp extension for template implementation files.)

I'm not sure if newly added rules like that will make it to program defaults. If they don't, well save a fresh project template with that rule added.


I'd kinda tend to agree with etresoft that you ought to look for another teacher though. Somebody who teaches you this kind of theoretically elegant but utterly out of touch with actual practice nonsense is not whom I would look for in a C++ teacher.

Dec 1, 2008 6:03 AM in response to Sirjacksinurbox

Sirjacksinurbox wrote:
new to the forum(My first posting).

I am working on a c++ project for school, and the teacher mandates that we use a .tpp file for our next program. I started out by just adding the .tpp file(named types.tpp), but it doesnt seem to pick up the syntax for c++ on it. How would I go about adding this file to my c++ project and still being able to incorporate all of the syntax rules and settings?


I've never seen nor heard of a ".tpp" extension. Are you sure the teacher didn't say ".cpp"? Does the teacher have an accent perhaps? If such as extension is meant for templates, it would still be extraordinarily unusual to teach templates in any class, let alone an introductory class. I doubt templates are the issue either because I've never seen them use such an extension either. I am almost certain these files should be ".cpp". If not, you should consider another teacher.

Dec 1, 2008 7:23 AM in response to etresoft

I am positive, we already deal with .cpp and the header files that go with it. And he is 100% american i believe(a real character at that). This is actually the second class for C++ offered at my university. I just think of it as introductory because there are apparently so much more you can do with the language that he does not teach us. But the problem still remains with this tpp file extension. If it helps, the name of the file is "types.tpp"


btw: Thanks for the info eric

_Jack

Message was edited by: Sirjacksinurbox

Dec 1, 2008 10:58 AM in response to Sirjacksinurbox

I'm sorry to hear that. Follow eric's advice and you should be able to get Xcode to treat those files as C++ header files. It might also be a good idea to select one of those TPP files in the Finder, Get Info, and set "Open With" to be Xcode. Do a "Change All" for all TPP files.

It might be a good idea to double check anything you "learn" in that class. Feel free to post details here and we can tell you if it is something that make sense. While you are in this class, you will have to abide by the rules of the class, and that may mean using TPP files. Just be aware that what you are learning may not be mainstream. For example, if I Google "c++ tpp file extension", the #1 hit is this thread.

Dec 1, 2008 11:07 AM in response to etresoft

"Just be aware that what you are learning may not be mainstream."

Far as I know this .tpp idea originated with STLplus. Haven't seen it anywhere else anyway. Let me see ... ah, here we go, the justification such as it is, down in point 4.

http://stlplus.sourceforge.net/stlplus/docs/guidelines.html

Doesn't sound very convincing to me. Most certainly not convincing enough to make your file extensions incompatible with all mainstream tools.

Dec 1, 2008 11:25 AM in response to alexcurylo

alexcurylo wrote:
First off, tell the teacher he's being a twit since .h files work just fine


I wouldn't recommend that. My advice is go with the flow and don't raise a stink. The original poster could learn quite a bit from this class. I had one professor who was very close to being insane and wanted everyone to program everything in assembly. I can learn Objective-C, XSL, etc. on my own, but having those formative years in assembly were very helpful.

it's only the most anal of annoying twits like the STLplus clowns who insist on inventing some distinction between implementation and definition of templates for no particularly useful reason in the world and to the immense inconvenience of people who actually use production tools none of which have a clue what on earth "tpp" might be, as you've seen in this thread already.


I wouldn't disagree with that. I had never heard of STLplus either until this thread. If you are working in C++ and working with templates, it would be far better to embrace them and learn how they work than fear them and hide them in a TPP file.

Second off, drop your C++ class


Again, I disagree. The original poster could still learn C++ just fine in this class. We don't know all the details.

take up Objective-C so you can use a dynamic language where stupid compiler tricks like templates aren't necessary in the first place. Seriously. A handful of Cocoa projects later, you're going to be looking at your old C++ projects thinking "Why the @(#$&@&#!! did it ever make sense to have to write this kind of stupid @#($&@#$&!!!"


... but I don't disagree with this. I spent many years mastering C++, then starting doing a lot of Perl and Objective-C. I certainly learned an awful lot about programming by learning C, C++, and templates and that experience is invaluable. However, I don't expect I will ever code in C++ again.

Okay, moving on to immediately practical recommendations now, what you should do is select your project target in the inspector, go to the 'Rules' tab and add a new rule for .tpp -- and contrary to Eric's instructions above, make it "sourcecode.cpp.h" not "sourcecode.cpp.cpp".


Yes. A very good idea. You don't want Xcode trying to compile these files. Xcode can include any file with any extension. All you want to get out of it is syntax hi-lighting.

I'd kinda tend to agree with etresoft that you ought to look for another teacher though. Somebody who teaches you this kind of theoretically elegant but utterly out of touch with actual practice nonsense is not whom I would look for in a C++ teacher.


I doubt there is any "theoretical elegance" involved. The STLplus people may think that, but we have no idea what is going through the head of this guy. If you have the option of other teachers, go for it. If not, stick it out, and learn C++ on your own. There are plenty of resources to help with that.

As for the class, render unto Caesar that which is Caesar's. Sadly, you can't always (or even often) avoid bad teachers. Just try to make the best out of it that you can.

Dec 1, 2008 11:46 AM in response to etresoft

etresoft wrote:
alexcurylo wrote:
First off, tell the teacher he's being a twit since .h files work just fine


I wouldn't recommend that. My advice is go with the flow and don't raise a stink. The original poster could learn quite a bit


Well, that statement was mostly sarcastic -- thus the distinction I made further down between my first reactions and practical recommendations -- but if it was me I would at least bring up the point that this is a very oddball practice and therefore it's going to confuse coworkers and make working with standard tool chains inconvenient for no particularly good reason, just to see what his justification is. Perhaps there actually is some kind of good reason, although I certainly can't conceive of it.

However, it certainly would be more prudent to just smile and nod for the moment and proceed to forget this idea as soon as the final exam is over and just avoid this prof in future, yes.

Dec 1, 2008 6:54 PM in response to alexcurylo

Trust me when I say: After this class, I will probably never touch C++ again. cocoa and other languages do perk my interest. And yes, they do have an assembler class at my college, all with machine language and data structures... thats why I'm an IT Major and not software development. I cant wait to learn C#(thats what my company develops in)

As it stands, a lot of the teachers in my department are used to doing things the archaic way. I'm in an intro IT systems class and the teacher is reaching advanced hashing and sorting techniques. All of the teachers use unix command line editors(nobody uses an IDE... wait one does, he uses PSPad). A lot of the students have a hard time because they dont see the big picture that you get with IDE's when they program from a putty shell...


Thank you all for the advice btw.

null

Dec 1, 2008 7:37 PM in response to Sirjacksinurbox

Sirjacksinurbox wrote:
Trust me when I say: After this class, I will probably never touch C++ again. cocoa and other languages do perk my interest. And yes, they do have an assembler class at my college, all with machine language and data structures... thats why I'm an IT Major and not software development. I cant wait to learn C#(thats what my company develops in)


Learning assembly, data structures, and C++ will help you with C# too. You don't have to wait to learn C#, you can do it right now on your Mac using Mono.

As it stands, a lot of the teachers in my department are used to doing things the archaic way. I'm in an intro IT systems class and the teacher is reaching advanced hashing and sorting techniques.


It isn't that it is archaic. They are trying to get you to think in a logical fashion. No one expects intro classes to be useful. They are a way to gauge if you are a good fit for the program. They only time you will ever have to do any hashing or sorting after this class is in a job interview.

And I'm not joking here. I interviewed at a fancy NYC hedge fund where they asked me questions just like that. Hmmm. I've got several, billion-dollar pieces of hardware running my software and you're asking me whether heapsort is O(log N) or O(N log N)? Perhaps that is why I'm still employed and those people are all laid off now 🙂

All of the teachers use unix command line editors(nobody uses an IDE... wait one does, he uses PSPad). A lot of the students have a hard time because they dont see the big picture that you get with IDE's when they program from a putty shell...


Actually, you get a much better "big picture" view from using a UNIX command-line. If all you know is an IDE, you're lost when you have to use a new IDE. For people who know how it all works underneath (after mastering the command line), one IDE is the same as the next.

I don't know about the TPP fellow, but it sounds like some of your professors may know what they are doing. Even with him, perhaps there is a method to his madness. Stay put, keep quiet, learn C++ and the command line. Even if it may not seem useful in the short term, it will definitely pay off in the long term. Trust me 🙂

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

XCode C++ Question (.tpp files)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.