Jump to content
  • Advertisement
Sign in to follow this  
Jampol

Am I understanding typedef correctly?

This topic is 2520 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've got a feeling that I'm wrong on this subject, so here it goes. From what I've come to understand from Google is that typedef doesn't affect the compiler in any way, it's for telling other programmers (and possibly a reminder for yourself) that the (int, var, ect.) is brand new to that section of code and hasn't been pulled from anywhere else in the project. Am I close?

Share this post


Link to post
Share on other sites
Advertisement
No. A typedef provides an alias for an existing type; it's just a new identifier that refers to an existing type.

Share this post


Link to post
Share on other sites
Alright so for a rough example:

typedef int volume_soup;

volume_soup amount_soup;

changing the integer representation from volume_soup to amount_soup for the rest of the code until told otherwise, correct?

Share this post


Link to post
Share on other sites
No, first declares that volume_soup is an alias for int, then creates a new variable called amount_soup of type int.

Share this post


Link to post
Share on other sites
Alright that makes sense, thanks for steering me in the right direction. I'll start experimenting with typedef tonight.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!