Compilation error when using a extern function ?

tsalm tsalm at free.fr
Thu Nov 20 14:57:11 PST 2008


Hello,


I'm on DMD 1.036.
When I'm compiling this code :

// -------------CODE-----------------------


enum ColorValues:uint
{
      AliceBlue  = 0xF0F8FFFF
     ,AntiqueWhite  = 0xF8ECD8FF
     ,Aqua  = 0x00FFFFFF
     ,Aquamarine  = 0x80FFD0FF
     ,Azure  = 0xF0FFFFFF
     ,Beige  = 0xF8F4E0FF
     ,Bisque  = 0xFFE4C8FF

      [...]


Color convertToColor(uint val)
{
     ubyte[4] colorVal = *cast(ubyte*)&val;

     return Color(    colorVal[0]
                     ,colorVal[1]
                     ,colorVal[2]
                     ,colorVal[3]
                  );
}

class DFLCalendar:Panel
{
     // Graphicals objects
     protected
     {
         // Colors default preferences :
         const Color colorPanMonth  =  
convertToColor(cast(uint)ColorValues.MidnightBlue);
         const Color colorPanDays   =  
convertToColor(cast(uint)ColorValues.White);
         const uint  heightPanMonth = 16 ;
         const uint  widthButChangeMonth = 10;
	
	[...]
// -------------END CODE-------------------

The compiler return me the error :

	tools\gui\tools\DFLCalendar.d(29): Error: cannot evaluate  
convertToColor(404254975u) at compile time

Line 29 corresponds to "const Color colorPanMonth  =  
convertToColor(cast(uint)ColorValues.MidnightBlue);"


Thanks in advance for your help,
TSalm


More information about the Digitalmars-d-learn mailing list