Author Topic: SE2009: Slick-C Pointer initialization problems in classes  (Read 4025 times)

byates

  • Senior Community Member
  • Posts: 106
  • Hero Points: 8
SE2009: Slick-C Pointer initialization problems in classes
« on: March 21, 2009, 07:51:14 PM »
The following applies to Slick-C macros using classes:

When initializing a pointer to null within a class, I get an compilation error saying the type is invalid.  The same initiailzation works fine outside of a class.  This problem is new to 2009.

In the following code example, Ptr1 produces a type mismatch error while Ptr2 works just fine.

Code: [Select]
#pragma option(pedantic,off)
class test
    {
    int* Ptr1 = null;  // Type mismatch
    };

int* Ptr2 = null; // Ok

byates

  • Senior Community Member
  • Posts: 106
  • Hero Points: 8
Re: SE2009: Slick-C Pointer initialization problems in classes
« Reply #1 on: March 27, 2009, 04:22:32 PM »
A work around to this issue is to initialize the pointer member to null in the class constructor.  It seems (so far) that the only place a pointer can't be set to null is in the member declaration.