Jump to content
  • Advertisement
Sign in to follow this  
Sylvarant

shadows a parameter

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

when compiling my code it gives this error,Font.cpp declaration of 'FONT*fontpointer' shadows a parameter I'm using allegro so the types and functions are OK
 
Font::Font(char*fontname,FONT*fontpointer,PALETTE palette) { 
   numfont++;
   FONT * fontpointer; 
   PALETTE palette; 
   fontpointer = load_font(fontname,palette, NULL); 
   if(!fontname){ 
     allegro_message("failed to load font%s",allegro_error);             
}                         
}

Font.cpp declaration of 'FONT*fontpointer' shadows a parameter

Share this post


Link to post
Share on other sites
Advertisement

Font::Font( char * fontname, // #1, parameter named "fontname"
FONT * fontpointer, // #2, parameter named "fontpointer"
PALETTE palette) // #3, parameter named "palette"
{
numfont++;
FONT * fontpointer; // #4, local variable named "fontpointer"
// hides ('shadows') #2
// #2 can no longer be accessed
PALETTE palette; // #5, local variable named "palette"
// hides ('shadows') #3
// #3 can no longer be accessed

// following statement means: #4 = load_font(#1, #5, NULL);
// #5 is default initialised, not the value that was
// passes in to #3
fontpointer = load_font(fontname,palette, NULL);
if(!fontname)
{
allegro_message("failed to load font%s",allegro_error);
}
}
You almost certainly want to remove the two local variable definitions. You may also want to pass fontpointer by reference to pointer depending on what's supposed to be happening, although if that is what is desired then the design would seem to be a bit icky.

Σnigma

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!