C99 structure initialisers and Samba3

tridge at samba.org tridge at samba.org
Tue Aug 22 21:13:24 GMT 2006


I've been looking at what needs to be done for ldb to be used in
Samba3. Mostly it is fairly trivial, but I have hit one snag.

The problem is structure initialisers like this:

 static const struct ldb_module_ops operational_ops = {
	 .name              = "operational",
	 .search            = operational_search,
	 .add               = operational_add,
	 .modify            = operational_modify,
	 .init_context	    = operational_init
 };

this is a C99 style structure initialiser. We decided to start using
these in Samba4 to reduce the incidence of coding errors due to
incorrect structure initialisation.

The price we paid for this is that we can't compile on older versions
of cc on Solaris. In particular the cc used on Solaris8 and Solaris9
doesn't support this. The one in Solaris10 seems to be fine (ie. its
fine on SunX in the build farm). I can't see any other compilers in
the build farm that are affacted by this. Of course, there are other
compilers that don't support C99 structure initialisation, but in
every other case they are also missing some other feature that Samba3
already relies on. So it looks like its only older solaris versions
where this makes a difference.

Any comments on this tradeoff? Forcing people to use gcc on older
versions of Solaris doesn't seem too bad to me, given the advantages
in terms of code robustness.

Of course, we could use an #ifdef or just not compile that module in
Samba3, so this particular snag isn't a showstopper, but it would be
nice to be able to share code like this in future if other common code
is cleaned up to use C99 initialisation.

Cheers, Tridge


More information about the samba-technical mailing list