views:

127

answers:

2

Hi everyone,

I am working on a C++ project on macOS X 10.6.2 with xcode.

I tried to compile my code on windows and do not have any problem, I guess Linux is working but I don't have one with me right now.

My problem is xcode do not accept this kind of instruction :

struct direction {
double x;
double y;
double z;
double t; };

typedef struct direction direction;

Here is my error :

/Users/sbarbier/dev/xcode/Infographie/TP9-RayTracing/RayTracing-Direction.h:22:0 /Users/sbarbier/dev/xcode/Infographie/TP9-RayTracing/RayTracing-Direction.h:22: error: changes meaning of 'direction' from 'typedef struct direction direction'

I am using GCC4.2 and haven't change anything. This code works on every platform, can any one help me ?

A: 

Did anyone never had this problem ?

Sebastien BARBIER
Give people time to see your question, no need to bump it. I'd delete this before you get down voted.
GMan
Stack Overflow is not a discussion forum; "bumping" your question like this is inappropriate.
Chris Hanson
A: 

This isn't C. In C, to use a struct you had to use the keyword struct:

struct some_struct{ int i; };
struct some_struct myStruct;

This was alleviated like this, commonly:

typedef struct { int i; } some_struct;
some_struct myStruct;

In C++ this is not required. direction already has a type, then you're trying to make a new type of the same name, and that's bad. Take out your entire typedef, it isn't needed.

GMan