Sign in to follow this  
Sylvarant

shadows a parameter

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this