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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:57:27+00:00 2026-05-28T05:57:27+00:00

I am reading a book which mentions this If the compiler knows every use

  • 0

I am reading a book which mentions this

If the compiler knows every use of the const, it need not allocate
space to hold it. For example:

  1. const int c1=1;
  2. const int c3=my_f(3);
  3. extern const int c4;

Given that values of c3 and c4 are not known as compile time, storage
must be allocated for c3 and c4.

I didn’t understand any of this. My doubts are:

What does it mean by holding here? Wouldn’t it still need to store everything in memory?
For c1, wont we have any storage allocation?

Please clear my doubts.

Thank you.

  • 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-28T05:57:28+00:00Added an answer on May 28, 2026 at 5:57 am

    c1 is different from the other two constants in that it is initialized with a literal value. This lets compiler put that value everywhere the constant is used, like this:

    int x = z + c1;
    

    can be replaced by

    int x = z + 1;
    

    This means that the compiler does not need to allocate space and store 1 in it.

    c3 and c4 are different: one is calculated using a function, and the other one is supplied from a different compilation unit. This means that the compiler can no longer perform the substitution the way it could with c1: the values of the c3 and c4 are not known to the compiler. Therefore the compiler generates code for

    int x = z + c4;
    

    in the same way as if c4 were a variable stored in some place in memory. Since in this case c4 is an external constant, the linker will resolve its location, and fill in the information the compiler is missing (namely, the address of c4) to make the program complete and ready to run.

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

Sidebar

Related Questions

I'm reading a book which says not to use such a code: private volatile
I'm reading this introductory book on parsing (which is pretty good btw) and one
I'm reading this book: http://eloquentjavascript.net/ which I think is brilliant. However I'm having difficulty
Getting this error in Xcode 4. I am reading a book which uses 0.99.5
I'm reading a book called C++ Gotchas which explains the conversions between const pointers
I was reading this book Art of Exploitation, which is kinda good book and
I've been reading a book which is in C#. I'm a VB.NET developer (and
I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which
In the book of application architecture design, which I'am reading, I've found the following
So I'm reading The Art & Science of Javascript, which is a good book,

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.