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 7166477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:25:13+00:00 2026-05-28T14:25:13+00:00

Given the following code snippet: type MyIntf = interface [‘{C6184693-663E-419F-B2DA-4DA1A0E33417}’] procedure Foo; end; InvisiblePropInterfaces

  • 0

Given the following code snippet:

type
  MyIntf = interface
    ['{C6184693-663E-419F-B2DA-4DA1A0E33417}']
    procedure Foo;
  end;

  InvisiblePropInterfaces = class(TCustomAttribute)
  private
    FGUIDS: array of TGUID;
  public
    constructor Create(const GUIDS: array of TGUID);
  end;

  [InvisiblePropInterfaces([MyIntf])]  // <-- Constant expression expected error
  TMyClass = class(TInterfacedObject, MyIntf)
    procedure Foo;
  end;

Why does the compiler think this is not a constant expression ?
But given that I use InvisiblePropInterfaces like this, the compiler is just happy?

...
var
  I: InvisiblePropInterfaces;
begin
  I:= InvisiblePropInterfaces.Create([MyIntf]);
...
  • 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-28T14:25:14+00:00Added an answer on May 28, 2026 at 2:25 pm

    The pertinent section of the attributes documentation is this:

    It is important to understand that the values passed to the attribute’s constructor must be constant expressions. Because those values must be embedded directly into the resulting binary, it is impossible to pass an expression that requires run-time evaluation. This raises a few limitations to the information that can be passed to the attribute at compile time:

    • Only constant expressions are allowed, including sets, strings, and ordinal expressions.
    • out and var parameters cannot be used, because they require run-time evaluation of addresses of passed parameters.
    • Addr() intrinsic and @ operator cannot be used.
    • The TypeInfo() operator can be used to pass type information, because the RTTI block addresses are known at compile time.
    • Class references are allowed, because the metaclass addresses (as the case of TypeInfo()) are known at compile time.

    The key point is that a constant expression is a technical Pascal term that is not the same thing as a constant. I suspect that this is the root of the confusion.

    Since it is not possible to have a constant expression that can be passed to a TGUID, you are out of luck with your attribute. Indeed it is just as impossible to have a constant expression that can be passed to an open array parameter.

    I suppose that you could use the string representation of the GUID to solve the conundrum but that will leave you with messy duplication and an inability to pass arrays of GUIDs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath
Given the following code snippet: $i= 11; function get_num() { global $i; return (--$i
Question: Given the following code snippet: bool foo(int n) { for(int i=3;i<sqrt(n)+0.5;i+=2) { if((n%i)==0){
Given the following HTML code snippet; after finding the link by ID, how would
Given the following code snippet: using System; using Foo = System.Int32; namespace ConsoleApplication3 {
Given the following code snippet below, using GetPropValue(MyComponent,'MySubComponent.Prop1') raises an EPropertyError exception. How can
Given the following code snippet: int[] arr = {1, 2, 3}; for (int i
Given the following code (that doesn't work): while True: # Snip: print out current
given the following code: import ctypes ip=192.168.1.1 thisdll = ctypes.cdll['aDLL'] thisdll.functionThatExpectsAnIP(ip) how can I
Given the following code: var people = new List<person>(){ new person { Name =

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.