Recent

Author Topic: Does anyone know why these code cannot be compiled by the fpc?  (Read 2298 times)

TYDQ

  • Full Member
  • ***
  • Posts: 102
Code: Pascal  [Select][+][-]
  1. type efi_guid=record
  2.               data1:dword;
  3.               data2:word;
  4.               data3:word;
  5.               data4:array[1..8] of byte;
  6.               end;
  7. const efi_loaded_image_protocol_guid:efi_guid=($5B1B31A1,$9562,$11D2,($8E,$3F,$00,$A0,$C9,$69,$72,$3B));
It seems have no problem in pascal,why these pascal code cannot be compiled and show the error that Syntax error, "identifier" expected but "ordinal const" found?

Laksen

  • Hero Member
  • *****
  • Posts: 785
    • J-Software
Re: Does anyone know why these code cannot be compiled by the fpc?
« Reply #1 on: April 19, 2024, 03:04:14 pm »
The proper way to initialize a record is to name each field:
Code: Pascal  [Select][+][-]
  1. const efi_loaded_image_protocol_guid:efi_guid=(data1: $5B1B31A1; data2:$9562; data3: $11D2; data4: ($8E,$3F,$00,$A0,$C9,$69,$72,$3B));

A nice shortcut if you use instead the inbuilt TGuid is that you can write:
Code: Pascal  [Select][+][-]
  1. const efi_loaded_image_protocol_guid: TGuid = '{5B1B31A1-9562-11D2-8E3F-00A0C969723B}';

TYDQ

  • Full Member
  • ***
  • Posts: 102
Re: Does anyone know why these code cannot be compiled by the fpc?
« Reply #2 on: April 20, 2024, 05:24:32 am »
The proper way to initialize a record is to name each field:
Code: Pascal  [Select][+][-]
  1. const efi_loaded_image_protocol_guid:efi_guid=(data1: $5B1B31A1; data2:$9562; data3: $11D2; data4: ($8E,$3F,$00,$A0,$C9,$69,$72,$3B));

A nice shortcut if you use instead the inbuilt TGuid is that you can write:
Code: Pascal  [Select][+][-]
  1. const efi_loaded_image_protocol_guid: TGuid = '{5B1B31A1-9562-11D2-8E3F-00A0C969723B}';
Thank you,Problem solved.

 

TinyPortal © 2005-2018