Sign in to follow this  
dinotoast

DirectX Errors

Recommended Posts

dinotoast    122
I am getting some weird errors from the following code:
//CODE I AM GETTING ERRORS FROM

CUSTOMVERTEX vertices[4];

vertices[0] = CreateVertex(150.0f, 50.0f, 0.5f, 0, 0);
vertices[1] = CreateVertex(250.0f, 50.0f, 0.5f, 1, 0);
vertices[2] = CreateVertex(250.0f, 150.0f, 0.5f, 1, 1);
vertices[3] = CreateVertex(150.0f, 150.0f, 0.5f, 0, 1);

//HEADER FILE CONTAINING CreateVertex method
/**
*D3DUtils.h
*Contains utility methods for D3D.
*Author: Kane McGovern
*Revision: 25 November 2004
*/

#ifndef D3DUtils
#define D3DUtils

//CUSTOM VERTEX//////////////////////
struct CUSTOMVERTEX
{
	float x, y, z;
	float tu, tv;
};	//close CUSTOMVERTEX struct

CUSTOMVERTEX CreateVertex(float newX, float newY, float newZ, float newTu, float newTv)
{
	CUSTOMVERTEX vertex;

	vertex.x = newX;
	vertex.y = newY;
	vertex.z = newZ;
	vertex.tu = newTu;
	vertex.tv = newTv;

	return vertex;
}	//close CreateVertex method

#endif

The errors I am getting are: C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(48) : error C2466: cannot allocate an array of constant size 0 C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(48) : error C2501: 'vertices' : missing storage-class or type specifiers C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(48) : error C2371: 'vertices' : redefinition; different basic types C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(46) : see declaration of 'vertices' C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(48) : error C2440: 'initializing' : cannot convert from 'struct CUSTOMVERTEX' to 'int []' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(49) : error C2501: 'vertices' : missing storage-class or type specifiers C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(49) : error C2369: 'vertices' : redefinition; different subscripts C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(46) : see declaration of 'vertices' C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(49) : error C2440: 'initializing' : cannot convert from 'struct CUSTOMVERTEX' to 'int [1]' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(50) : error C2501: 'vertices' : missing storage-class or type specifiers C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(50) : error C2369: 'vertices' : redefinition; different subscripts C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(46) : see declaration of 'vertices' C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(50) : error C2440: 'initializing' : cannot convert from 'struct CUSTOMVERTEX' to 'int [2]' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(51) : error C2501: 'vertices' : missing storage-class or type specifiers C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(51) : error C2369: 'vertices' : redefinition; different subscripts C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(46) : see declaration of 'vertices' C:\Kool\Game Dev\D3DDemo\d3ddemo.cpp(51) : error C2440: 'initializing' : cannot convert from 'struct CUSTOMVERTEX' to 'int [3]' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Any ideas what is going on?

Share this post


Link to post
Share on other sites
Metron    268
The usual check list :

- have you included the header file ?
- Are you sure that D3DUtil isn't used already by DX itself ?
- Is CUSTOMVERTEX already defined in a different manner ?

Seems that the header isn't included as should.

Best regards,
Metron

Share this post


Link to post
Share on other sites
Mezz    571
You're going to need to post some more code before I can figure exactly what's going on. One thing is that it looks like you're trying to initialise the array by calling functions outside of any execution block. Also, if you're defining that CreateVertex() function in the header file and it's not inline you'll probably have link errors if the header is included anywhere else. There may be other issues but I can't see from that snippet.

-Mezz

Share this post


Link to post
Share on other sites
my guess is that the code is at global scope, ie: not in a function. The code is then interpreted as a new array missing a type, so it's assuming int, then complaining that you've asked for it to be 0 size, then complaining that you're not assigning it int values.

Then another array.. etc.

It's not expecting code because it's not in a function.

Share this post


Link to post
Share on other sites
dinotoast    122
Jeeeesus...I knew it would be something simple...

What a weiner I am...like you have said, the code is in global space and not in a function...thanks yall

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this