Re: "gcc" complains about a constant being non constant...(sorry for dup)

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

 



"Linda A. Walsh" <gcc@xxxxxxxxx> writes:

> Compile time output:
> ct.c:10: error: initializer element is not constant
> ct.c:11: error: initializer element is not constant

If you compile the program as C++ rather than C, then these
errors go away, and GCC 4.3.1 propagates the constants to the
printf call:

	movl	$6, 8(%esp)
	movl	$7, 4(%esp)
	movl	$.LC0, (%esp)
	call	printf

This is one difference in the meaning of const between C and C++.
Another difference is that in C++, const variables defined
outside of functions are static by default, although one can
override that with extern.  That doesn't matter in your program
because the variables were static already.

[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