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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:11:00+00:00 2026-05-11T15:11:00+00:00

I am using Delphi 2007 with all patches and updates. I have a file

  • 0

I am using Delphi 2007 with all patches and updates.

I have a file which is used by two different projects. In that file is a procedure, which I will simplify as follows:

procedure MyProcedure; const   UniqueValue: integer = 0; begin   //some code   Inc(UniqueValue);   //some more code end; 

The Inc() command should fail, because you cannot assign to a constant. In one project, I get an error to that effect (I’ll call that project ‘Accurate’). In the other project, I don’t get any errors (I’ll call it ‘Bogus’). I also don’t get any warnings. I can’t figure out why the compiler lets this incorrect code through.

Here’s what I’ve tried in project Bogus:

1 – Introduce an obvious error, like typing ‘slkdjflskdjf’ in the middle of a line

Result: I get an error,which proves that it is really trying to compile this file.

2 – Delete the .DCU, and rebuild the project

Result: The .DCU is re-generated, again proving that the project is truly compiling this erroneous code.

Does anyone have thoughts on why this behavior would occur? And more specifically, why it would occur in one project but not another? Is there some obscure compiler option to permit assigning to constants?

One final note: Both projects are converted from Delphi 5. Under Delphi 5 with similar code, they both compile fine.

Edit: Thanks for all your help. After changing the assignable typed constants directive, I can get consistent behavior across both projects. I learned something new today…

  • 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. 2026-05-11T15:11:00+00:00Added an answer on May 11, 2026 at 3:11 pm

    There is an option for this called ‘Assignable typed constants’ in Compiler Options. It can also be enabled with ‘{$J+}’ in your code.

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

Sidebar

Related Questions

Newer Delphi versions (including Delphi 2007, which I'm using) have a build in file
I'm using Delphi 2007 Pro. I have a runtime package that includes a number
I am using Delphi 2007 and I am trying to make record type file.
How can I check using Delphi 2007 that a box is AVX capable. My
Using the following code in Delphi 2007: procedure TfrmTest.PaintBox1Paint(Sender: TObject); const Rect_Size = 10;
I'm using Delphi 2007. I need write a FormatDateTime function that always return 01/01/
I've written a Windows service in Delphi 2007 using Indy 10 (10.5.8.0) that connects
I have a DLL compiled in Delphi 2007 and an example using it in
I'm using Delphi 2007 and I have this case: { CommonUnit.pas } type //
I'm working in Delphi 2007. Net, where I can find an example of using

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.