Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

PrettySneaky

linked list in c problem

This topic is 5218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have just copy pasted this piece of code from one project to another.

typedef struct _BoundingVolume
{
	ExpandedVolume encloseVolume;
	
	Geometry *geom;
    
	_BoundingVolume	*leftChild;
	
	_BoundingVolume	*rightChild;

	Vec3f	h;

} BoundingVolume;

But VS .NET doesn't whant to compile it? I can't understand why because I have wrote and used this data type on a different program. I get this error message: error C2061: syntax error : identifier '_BoundingVolume' [edited by - SiCrane on June 9, 2004 5:34:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
Have the other types you used been declared?

P.S. Generally ''bad'' language isn''t considered appropriate in the forums outside of the L*unge.

Share this post


Link to post
Share on other sites
Nothing wrong with that make sure your including the declartion of the types before _BoundingVolume.

Share this post


Link to post
Share on other sites

Sorry about the bad language. This #¤%&#¤%& code just drives me insane.

I have defined the other datatypes above _BoundingVolume in my header.

AND, the code have worked on other projekt.. :[

Bah!

Share this post


Link to post
Share on other sites
Ok!

I tried to an extremely simple linked list



typedef struct _ll
{
_ll *next;
int i;
} LL;



Still the same error message.. THIS SHOULD work. What the hell is wrong with my compiler. It do work if i start a new project and just define this single datatype och and declare it in the main func.. ??!?!

Share this post


Link to post
Share on other sites
Perhaps the thing immediately before it is missing a semicolon, or missing a closing brace. Usually errors that make no sense are because of a problem immediately above.

Another unlikely possibility is that you''ve #defined typedef or struct.

Share this post


Link to post
Share on other sites

Doesn''t seem to be that. I defined the struct in several different files and compiled... Same error

And I have not define struct of typedef..

Ahh..

Share this post


Link to post
Share on other sites
try this:

typedef struct STRUCTNAME_BLAH {
float x, y;
};


STRUCTNAME_BLAH myInstance;


I think that if you are using typedef, that you don''t want to have the variable declared in the same statement. I don''t remember exactly, but i''ve had the same problem before and did something similar to what i stated to fix it.

Share this post


Link to post
Share on other sites


typedef struct _ll
{
struct _ll *next;
int i;
} LL;



You need to use the non-typedef''d struct name if you want to have a pointer to its own type, with the word struct before it too.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share this post


Link to post
Share on other sites

Yes!! Thanx!

I guess the reason that my code didn''t work was because that it is a pure c program. My old program that i ripped the code from whas a c++ program without OO.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!