Questions

I feel sorry for always posting questions not answers.
My first question is

  1. When you use xcode for OpenGL programming why do we need “carbon application” for project target and “cocoa framework” for framework (why not carbon framework?) in addition to GLUT and OpenGL framework?
    (what is carbon and what is cocoa?)

http://onesadcookie.is-a-geek.net/~keith/XcodeGLUT/

  1. When I do OpenGL coding one of my source file has class “Point” defined and it conflicts with class “Point” inside MacTypes.h from carbon application header. In other words, when I compile the code it says:

error: redefinition of ‘class Point’ — Point.h
error: previous definition of ‘class Point’ — MacTypes.h

Is there any solution to this problem except changing the name of ‘class Point’?

Thanks in advance.

idaydream

short answer to the “carbon app” question is, Xcode is buggy. If you make a Cocoa app, main must be main.m – Objective C source. the carbon app template works with main.c.

As for Point, you could not include MacTypes.h – where’s it coming from and why do you need it?, or you could

#define Point MacPoint
#include <WhateverIncludesMacTypes.h>
#undef Point

or you could just rename your class.

Problem with not including MacTypes.h is that

first, I don’t know how to do it because it is one of the carbon core file.

/*
File: CarbonCore/MacTypes.h
Contains: Basic Macintosh data types.
Version: CarbonCore-545~1
Copyright: © 1985-2003 by Apple Computer, Inc., all rights reserved.
*/

second, when I tried

#define Point MacPoint
#include <CarbonCore/MacTypes.h>
#undef Point

in Point.h and MacTypes.h one by one but it does not work and I don’t want to change my Point class name. Now, those being said, what should I do now…?

You can use namespace (only if you are using C++)

I ask again, why are you including Carbon?

you should only ever include Carbon by including Carbon/Carbon.h. This should work:

#define Point MacPoint
#include <Carbon/Carbon.h>
#undef Point

If Carbon is being implicitly included by something else, you’ll need to make sure that comes before the other include.

Dear OneSadCookie,

I guess you are the one who made the famous “Xcode/GLUT Tutorial.”
It helped me a lot.

Goint back to the question, the thing is that I did not include Carbon.
I thought it automatically include itself when I choose a project target as Carbon Application as you described in “Xcode/GLUT Tutorial” doesn’t it?

Another problem is that I don’t know where to add the code you mentioned.

#define Point MacPoint
#include <Carbon/Carbon.h>
#undef Point 

One more thing is that when I try to do the same thing for MacTypes.h, Xcode cannot find the file (it is not in CarbonCore, Carbon, FlatCarbon)
In other words,

#define Point MacPoint
#include <Carbon/Mactypes.h>
#undef Point 
#define Point MacPoint
#include <CarbonCore/Mactypes.h>
#undef Point 
#define Point MacPoint
#include <FlatCarbon/Mactypes.h>
#undef Point

None of them works because it cannot find the MacTypes.h file.

The application was originally written in Visual Studio C++ with GLUT library and I am trying to make it work on Xcode.

Thanks alot. ^^

Like I said, you shouldn’t ever include the MacTypes.h header yourself. It’s not likely to work.

It sounds like Xcode may be using a precompiled Carbon header as a prefix – not very useful :slight_smile: If you can find a target setting for a prefix header, turn that off.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.