Re: How to use C89 with certain C99 features

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steffen Dettmer <steffen.dettmer@xxxxxxxxxxxxxx> writes:

> You cannot have const members with runtime data.
> As I understand it, the "small old" compilers may locate
> const data into ROM (or other RO memory), which makes it
> impossible to initialize it with runtime data, so again the
> problem may not be the compiler language / version, but
> properties of the equipment. If you want your code to be runable
> on such systems, you cannot use it.

In C89 or C99, a variable declared as const can not be modified after it
is created.  Any initializer of such a variable may contain only const
expressions.  So such a variable may be placed in read-only memory, and
gcc will in fact normally do so.  (There are some cases where this can
not be done when using -fpic).

C++ is more complicated, due to constructors and the mutable storage
class specifier.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux