Thread: What exactly is a const expression?

  1. #16

    Join Date
    Apr 2008
    Quote Originally Posted by Elysia View Post
    A function return is NOT considered a constant expression (although the next standard will add a feature that allows a return from a function to be interpreted as a constant expression).
    Yes, that is what I was trying to say.
    I guess the decision to call the readonly keyword `const' was misleading in that, from the compiler's perspective, its value will not necessarily be known at compile-time.

    Because it's more of a compiler-technical detail, a lot of programmers (myself included) are caught by surprise when their compiler gets angry about using a const, but not const expression, variable in a situation where a const expression is required.
    Last edited by rudyman; 07-14-2008 at 01:21 PM.

  2. #17
    Join Date
    Oct 2007
    Inside my computer
    Indeed. I agree it's misleading.
    And I also think that some things should be enhanced to allow for more constant expressions.
    Such as float, double, const char* in templates (at least the former), constant expression functions. That would be nice. Among other things.
    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. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 05:34 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 01:26 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM