Yet if I don't use the GetEnumName inline, it works!?!?
For example, I call GetEnumName and store the result in a string variable, and then use it in the Check() method. Oh, and Check() is define as follows; class procedure Check(pValue: boolean; pMessage: string = ''); procedure TtiTestCase.CheckObjectState( pObjectState: TPerObjectState; pData: TtiObject; const pMessage: string = ''); var objstate: string; begin Assert(pData.TestValid, cTIInvalidObjectError); objstate := GetEnumName(TypeInfo(TPerObjectState), Ord(pObjectState)); Check(pObjectState = pData.ObjectState, 'ObjectState: Expected <' + {$IFDEF FPC} {$Note Find out why TypeInfo doesn't work in this case! It can't be used directly??? } {$ENDIF} objstate + '> but got <' + pData.ObjectStateAsString + '> on ' + pData.ClassName + '. ' + pMessage); end; Why can I not use GetEnumName inline? Regards, - Graeme - On 27/10/06, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote:
Why do I get this error? /tiOPF/UnitTests/Common/tiDUnitUtils.pas(231,32) Error: type identifier not allowed here It works on other enumerated declarations, but not on this one. I am pretty sure this code worked before, as I have been using tiOPF under FPC since December 2005. I marked the location of the error with a comment in the code below. procedure TtiTestCase.CheckObjectState( pObjectState: TPerObjectState; pData: TtiObject; const pMessage: string = ''); begin Assert(pData.TestValid, cTIInvalidObjectError); Check(pObjectState = pData.ObjectState, 'ObjectState: Expected <' + GetEnumName(TypeInfo(TPerObjectState), Ord(pObjectState)) + // error occurs here ---^--- '> but got <' + pData.ObjectStateAsString + '> on ' + pData.ClassName + '. ' + pMessage); end; where TPerObjectState is declared as follows: TPerObjectState = ( posEmpty, posPK, posCreate, posUpdate, posDelete, posDeleted, posClean ) ; I am using FPC 2.1.1 (r4642) under Linux (kernel 2.6) on Intel P4 processor. Regards, - Graeme - -- There's no place like 127.0.0.1
-- There's no place like 127.0.0.1 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal