Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 761749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:52:32+00:00 2026-05-14T15:52:32+00:00

Consider: const clHotlight: TColor = $00FF9933; clLink = clHotLight; //alias of clHotlight [Error] file.pas:

  • 0

Consider:

const 
   clHotlight: TColor = $00FF9933;
   clLink = clHotLight; //alias of clHotlight

[Error] file.pas: Constant expression expected

and the alternate wording that works:

const 
   clHotlight = TColor($00FF9933);
   clLink = clHotLight; //alias of clHotlight

Explain.


Then consider:

const 
   AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}';
   SuperuserGUID = AdministratorGUID; //alias of AdministratorGUID

[Error] file.pas: Constant expression expected

And fix.

Edit: Added keyword const before declarations; someone didn’t believe they were const.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:52:32+00:00Added an answer on May 14, 2026 at 3:52 pm

    clHotlight: TColor = $00FF9933; is not a constant but a typed constant (=static variable), i.e. the compiler reserves a slot in memory for a TColor which will hold the value $00FF9933 initially at run time.
    Because that value can be changed later (with the Assignable Const option ON), it is not a real constant and cannot be accepted by the compiler in clLink = clHotLight;

    clHotlight = TColor($00FF9933); is strictly the same as clHotlight = $00FF9933;
    It is a true constant and the compiler will replace clHotlight by its value $00FF9933 wherever it appears in the code. And for clLink as well.

    Read on this SO question (In Delphi 7, why can I assign a value to a const?) and all the good answers there…

    EDIT: about TGUID…
    The problem is that writing AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}'; is not proper.
    It is using some compiler magic to call StringToGUID behind the scene, allowing the convenience to express the GUID as a string which they are not by nature. They are records.

    So, trying AdministratorGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}'; will not work. That is not a GUID…

    A workaround is to have a typed constant and variables pointing to the same memory area using the absolute directive:

    const
       AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}';
    var
       SuperuserGUID: TGUID absolute AdministratorGUID; //alias of AdministratorGUID
       RootGUID: TGUID absolute AdministratorGUID;      //alias of AdministratorGUID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following: int ival = 1.01; int &rval = 1.01; // error: non-const
Consider the following snippet (error handling missing on purpose): void* foo(const char *path, off_t
Consider the following header file example: shared_example.h #ifndef SHARED_EX #define SHARED_EX const int Shared_Int
Consider this code: const char* someFun() { // ... some stuff return Some text!!
consider the following code: const QString& MyClass::getID(int index) const { if (i < myArraySize
Consider the following code: struct Foo { Foo operator+(const Foo &rhs) const; // notice
Consider the following code: struct Calc { Calc(const Arg1 & arg1, const Arg2 &
Consider the following function: void f(const char* str); Suppose I want to generate a
Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters
const (and in ) Consider there is C function: unsigned int foo(const unsigned int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.