[Prev][Next][Index]

enum type in pC++



Hi,

I noticed recently that eumerated types are processed incorrectly
by pC++ in some contexts.

I am sending an example where a constant (X) of enumerated type
(dir_t) is not recognized in the assignment operator in function
MyCollection::efoo().

Even without this error, there would be a problem with further 
C++ compilation, as the word "typedef" would disappear from the declaration
	typedef enum {....} dir_t;
and dir_t therefore will not be declared as a type in  temp.C

I don't think that this is listed among the bugs in the user's guide.

	--Vladimir


/*------------- enum tests ------------------------------------*/
#include "pcxx.h"

class MyElement{
 public:
  void hello();
};

#include "kernel.h"

// Define the collection:
Collection MyCollection: SuperKernel
{
  public:
    MyCollection(Distribution *T, Align *A);
  MethodOfElement:
    void efoo();
};

MyCollection::MyCollection(Distribution *T, Align *A):SuperKernel(T, A)
{ };

/* In temp.C, the word "typedef disappears from the following declaration! */
typedef enum { X=0, Y=1} dir_t;

void boo1(int a) { //OK
  printf("%d", a);
}

void boo2() {  // OK
  boo1(X);
}

void boo3() { // problem in temp.C ("dir_t undeclared")
  dir_t b;
  b = X;
}

// MoE
void MyCollection::efoo() {
  int i;
  i = X;   // X not undersatnd by the preprocessor!
}

void Processor_Main()
{}