Jump to content
  • Advertisement

Archived

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

Riskbreaker

Declaring a constant array

This topic is 5576 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

static const void *const fixd_v[] = { ... } Here''s some C code you don''t see every day... Can anyone break this down and explain what each of the terms are doing? I just saw this in some code and I don''t quite understand why ''const'' is stated twice, as well as how ''static'' affects it. Thanks for any tips. As far as I can tell, however, it''s an array of void pointers...

Share this post


Link to post
Share on other sites
Advertisement
static = internal linkage (cannot be referenced outside of the translation unit (usually the .c|cpp) that it's delared in)

first const = pointer to const data (data pointed to cannot be changed)

second const = const pointer (pointer cannot be changed to point to something else)


so....

it's a const pointer to an array of const void pointers that can only be used within the source file (or translation unit) that it is declared in (i.e no other .h or .c|cpp files have access to that array).

[edited by - poontardis on June 17, 2003 9:24:34 AM]

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!