[C++-sig] Pyste bug with unnamed enums

Roman Yakovenko roman.yakovenko at actimize.com
Tue Feb 17 16:25:15 CET 2004


	Hi. I found bug in Pyste.

Description:
In your code you have 2 unnamed enum definitions

enum { SOME_CONST_1 = 32 };
enum { SOME_CONST_2 = 46 };

after running pyste on this code you will get 

// Unique type for unnamed enums
#ifndef PYSTE_UNIQUE_INT_DEFINED
#define PYSTE_UNIQUE_INT_DEFINED
template<int num>
struct UniqueInt {
   int v;
   enum { value=num };
   UniqueInt(int v_):
       v(v_)
   {}
   operator int() const
   { return v; }
};
#endif // PYSTE_UNIQUE_INT_DEFINED 

generated twice ( if you generate your code to the same module ).

The possible solution are: 
 1. To ask David Abrahams how we should export unnamed enums ( defined within class and within some namespace ).
 2. To use unnamed enums as global constants for enums defined within namespace.
     To define new class attribute if enum defined within class.
 3. To put definition of UniqueInt within BPL
 4. To generate different name for UniqueInt or to generate it within different namespace

As for me 
	1 - is preferred way
	2 - I don't know whether it is possible to know where enum come from, and whether it is smart to divide
	      in this way enums
	3 - David Abrahams must agree to such solution
	4 - patch, that could be written in 15 minutes, but it will be very, very ugly	
	     hint: to generate the struct definition in it's own namespace. ( namespace will be unique )

Also I will be glad to implement and to contribute a patch. 

Roman.




More information about the Cplusplus-sig mailing list