const int versus #define - does "const int" take up space in exe?

Discussion in 'C++' started by ThazKool, Jun 11, 2006.

  1. ThazKool

    ThazKool Guest

    I know that the "const int" declaration gives us more control with
    scoping. However if I make a file with thousands of const int
    declarations, will this increase exe size if I do not use them? I know
    that #define will only get used if the preprocessor encounters one.

    Thanks,
    ThazKool
    ThazKool, Jun 11, 2006
    #1
    1. Advertising

  2. ThazKool

    Guest

    ThazKool wrote:
    > I know that the "const int" declaration gives us more control with
    > scoping. However if I make a file with thousands of const int
    > declarations, will this increase exe size if I do not use them? I know
    > that #define will only get used if the preprocessor encounters one.
    >
    > Thanks,
    > ThazKool


    Any semi-competent compiler should optimize away all the const ints you
    don't use, so I wouldn't worry about it.

    -Sandra
    , Jun 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Freiberger
    Replies:
    3
    Views:
    919
    Bob Hairgrove
    Oct 30, 2004
  2. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,845
    Bryan Bullard
    Jul 11, 2003
  3. Replies:
    11
    Views:
    1,081
  4. John Goche
    Replies:
    4
    Views:
    594
    Victor Bazarov
    Nov 11, 2011
  5. Paul Butcher
    Replies:
    12
    Views:
    673
    Gary Wright
    Nov 28, 2007
Loading...

Share This Page