GCC 3.1.1 --std=c99: initializer element is not constant ...

Craig Newell craign@ieee.org
Sun May 26 12:19:00 GMT 2002


Hi There,

  I have some code that compiles fine with GCC 3.0.x but fails with GCC
3.1.x with an "initializer element is not constant" error.  Here is the
smallest example I could find:

--------------
typedef struct Lock Lock;

struct Lock {
	void *holder;
};

Lock lock = (Lock){ (void*)0 };
--------------

  Using GCC 3.0.x it builds fine with both "--std=c89" and "--std=c99" but
with "GCC 3.1.1 20020525 (prerelease)" it only builds with "--std=c89" and
fails with the "initializer element is not constant" error with
"--std=c99".  Is there some reason why "NULL (void *)0" is not constant
anymore in "c99"?

	Thanks,

		CraigN
--
      Craig Newell                email: CraigN@ieee.org
      Free Spirit                 icbm:  N 42°38'47" W 71°18'19"




More information about the Gcc-bugs mailing list