Q. Syntax of const 2D array cast (FAQ 5.7) 
Author Message
 Q. Syntax of const 2D array cast (FAQ 5.7)

static void g( const float a[][2] ) { } /* Intent: treat 'a' as read-only. */
int main( void )
{
  static float b[3][2];
  g( b ); /* Problem here: Incompatible pointer type assignment. */
  return 0;

Quote:
}

/*
Question: I understand from the FAQ (5.7) that:
  (1) The problem on line 5 above is due to an incomplete ANSI specification
      (const is not recursive like in C++) and
  (2) The solution is to use a cast but...

What _exactly_ is the proper syntax to achieve this _in the above example_?

I've tried various things, including typedefs, to no avail - I'm still stumped!
Can someone PLEASE modify the above code to include the correct cast syntax
and post and e-mail me the solution?

Thanks,

Stumped

*/



Mon, 24 Feb 1997 04:54:03 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Clean way to const-cast arrays of arrays?

2. Passing 2D arrays to functions with const.

3. Passing 2D arrays to functions with const.

4. Which 2D array of 2D array addressing method?

5. 2D array of pointers to 2D arrays

6. 2D arrays of const things

7. type casting a static 2d array

8. ANNOUNCE: Math::MatrixBool 5.7

9. ANNOUNCE: Bit::Vector 5.7

10. K&R 5.7,5.8,5.9

11. Type Casting Const Pointers to non const pointers

12. Q. [Casting] Losing 2147483647 elements????

 

 
Powered by phpBB® Forum Software