Foros del Web » Programación para mayores de 30 ;) » C/C++ »

erroral utiliza "union" en C++

Estas en el tema de erroral utiliza "union" en C++ en el foro de C/C++ en Foros del Web. Hola! chicos necesito correr un archivo que esta hecho en C++ y que fue elaborado en Visual Studio, cuando lo corro en Visual Studio funciona ...
  #1 (permalink)  
Antiguo 13/05/2010, 18:44
 
Fecha de Ingreso: octubre-2009
Mensajes: 20
Antigüedad: 14 años, 6 meses
Puntos: 0
erroral utiliza "union" en C++

Hola! chicos necesito correr un archivo que esta hecho en C++ y que fue elaborado en Visual Studio, cuando lo corro en Visual Studio funciona perfectamente pero cuando deseo correrlo en Dev C++ (que es lo que necesito) me arroja el siguiente error:

72 C:\Documents and Settings\MaryGaby\Escritorio\Ray tracing (Jacco Bikker)\Ray tracing 1\raytracer1\common.h
member

72 C:\Documents and Settings\MaryGaby\Escritorio\Ray tracing (Jacco Bikker)\Ray tracing 1\raytracer1\common.h
member `

Aqui les coloco el código del archivo:

Código:
// -----------------------------------------------------------
// common.h
// 2004 - Jacco Bikker - [email protected] - www.bik5.com -   <><
// -----------------------------------------------------------

#ifndef I_COMMON_H
#define I_COMMON_H

#include "math.h"
#include "stdlib.h"

typedef unsigned int Pixel;

inline float Rand( float a_Range ) { return ((float)rand() / RAND_MAX) * a_Range; }

namespace Raytracer {

#define DOT(A,B)		(A.x*B.x+A.y*B.y+A.z*B.z)
#define NORMALIZE(A)	{float l=1/sqrtf(A.x*A.x+A.y*A.y+A.z*A.z);A.x*=l;A.y*=l;A.z*=l;}
#define LENGTH(A)		(sqrtf(A.x*A.x+A.y*A.y+A.z*A.z))
#define SQRLENGTH(A)	(A.x*A.x+A.y*A.y+A.z*A.z)
#define SQRDISTANCE(A,B) ((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y)+(A.z-B.z)*(A.z-B.z))

#define EPSILON			0.0001f
#define TRACEDEPTH		6

#define PI				3.141592653589793238462f

class vector3
{
public:
	vector3() : x( 0.0f ), y( 0.0f ), z( 0.0f ) {};
	vector3( float a_X, float a_Y, float a_Z ) : x( a_X ), y( a_Y ), z( a_Z ) {};
	void Set( float a_X, float a_Y, float a_Z ) { x = a_X; y = a_Y; z = a_Z; }
	void Normalize() { float l = 1.0f / Length(); x *= l; y *= l; z *= l; }
	float Length() { return (float)sqrt( x * x + y * y + z * z ); }
	float SqrLength() { return x * x + y * y + z * z; }
	float Dot( vector3 a_V ) { return x * a_V.x + y * a_V.y + z * a_V.z; }
	vector3 Cross( vector3 b ) { return vector3( y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x ); }
	void operator += ( vector3& a_V ) { x += a_V.x; y += a_V.y; z += a_V.z; }
	void operator += ( vector3* a_V ) { x += a_V->x; y += a_V->y; z += a_V->z; }
	void operator -= ( vector3& a_V ) { x -= a_V.x; y -= a_V.y; z -= a_V.z; }
	void operator -= ( vector3* a_V ) { x -= a_V->x; y -= a_V->y; z -= a_V->z; }
	void operator *= ( float f ) { x *= f; y *= f; z *= f; }
	void operator *= ( vector3& a_V ) { x *= a_V.x; y *= a_V.y; z *= a_V.z; }
	void operator *= ( vector3* a_V ) { x *= a_V->x; y *= a_V->y; z *= a_V->z; }
	vector3 operator- () const { return vector3( -x, -y, -z ); }
	friend vector3 operator + ( const vector3& v1, const vector3& v2 ) { return vector3( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z ); }
	friend vector3 operator - ( const vector3& v1, const vector3& v2 ) { return vector3( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z ); }
	friend vector3 operator + ( const vector3& v1, vector3* v2 ) { return vector3( v1.x + v2->x, v1.y + v2->y, v1.z + v2->z ); }
	friend vector3 operator - ( const vector3& v1, vector3* v2 ) { return vector3( v1.x - v2->x, v1.y - v2->y, v1.z - v2->z ); }
	friend vector3 operator * ( const vector3& v, float f ) { return vector3( v.x * f, v.y * f, v.z * f ); }
	friend vector3 operator * ( const vector3& v1, vector3& v2 ) { return vector3( v1.x * v2.x, v1.y * v2.y, v1.z * v2.z ); }
	friend vector3 operator * ( float f, const vector3& v ) { return vector3( v.x * f, v.y * f, v.z * f ); }
	union
	{
		struct { float x, y, z; };
		struct { float r, g, b; };
		struct { float cell[3]; };
	};
};

class plane
{
public:
	plane() : N( 0, 0, 0 ), D( 0 ) {};
	plane( vector3 a_Normal, float a_D ) : N( a_Normal ), D( a_D ) {};
	union
	{
		struct
		{
			vector3 N;
			float D;
		};
		float cell[4];
	};
};

typedef vector3 Color;

}; // namespace Raytracer

#endif
El error de la linea "72" que mencione antes es en esta seccion:

Código:
	union
	{
		struct
		{
			vector3 N;
			float D;
		};
		float cell[4];
	};
Cuando se declara:
Código:
			vector3 N;
Se que es medio complicado pero de verdad ya no sabia a quien recurrir! Gracias de antemano por cualquier idea!

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:43.