Thread: More questions about constants

  1. #31
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    You could disassemble the executable. But what for? To find out whether you have 4 more bytes in the static section?

    Here's something you can try with only generating assembly:
    #include <iostream>
    const int CON = 100;
    int main()
    	std::cout << CON << '\n';
    Enable optimizations and find CON in the assembly output. (I tried this with GCC 3.4.4 and -O2)

    As long as you treat constants as constants and not as variables (e.g. take the address), they won't even be emitted. Size requirement: zero. Whereas if they're extern, they always need the space.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #32
    Join Date
    Oct 2007
    Inside my computer
    It's not so much practical effort, it's just that I want to know.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C interview questions
    By natrajdreams in forum C Programming
    Replies: 7
    Last Post: 12-12-2010, 12:40 PM
  2. many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  3. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  4. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  5. Trivial questions - what to do?
    By Aerie in forum A Brief History of
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM