Jump to content
  • Advertisement
Sign in to follow this  
l0calh05t

Why does this cause an error?

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

Minimal example:
void foo(const int** a)
{
	(void)a;
}

void bar(int** a)
{
	foo(a);
}

This causes a compiler error C2664 (compiler is VC++ 2008)
1>e:\development\softwareradio\modules\filter\dec_int\polyfir\main.cpp(22) : error C2664: 'foo' : cannot convert parameter 1 from 'int **' to 'const int **'
1>        Conversion loses qualifiers


Shouldn't casting from non-const to const be implicit? And single pointers do *not* cause this error... EDIT: And this works as well:
void foo(const int* const* a)
{
	(void)a;
}

void bar(int** a)
{
	foo(a);
}

Share this post


Link to post
Share on other sites
Advertisement
Neat, didn't think of that. And thanks for the quick reply :-) The const int* const* variant is the semantically correct way of expressing what I wanted anyways...

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.

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!