tech-userlevel archive

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

Re: Rationale for some rules in style guide



    Date:        Wed, 12 Apr 2023 22:01:36 +0200
    From:        Reinoud Zandijk <reinoud%NetBSD.org@localhost>
    Message-ID:  <ZDcOIBRFN4Rd0tHw%gorilla.13thmonkey.org@localhost>

  | Oh I do that for I think its more clear

You really write (and think it is more clear) stuff like:

	char a;
#if sizeof(struct small) == sizeof(char)	/* except you can't, I don't think */
	struct small b;
#endif
	char c;
	short aa;
#if sizeof(struct small) == sizeof(short) && sizeof(char) != sizeof(short)
	struct small b;
#endif
	short cc;
#if sizeof(struct small) > sizeof(short) && sizeof(struct small) > sizeof(char)\
    && sizeof(struct small) < sizeof(int)
	struct small b;
#endif
	int aaa;
#if sizeof(struct small) == sizeof(int) && ....
	struct small b;
#endif
#if sizeof(size_t) == sizeof(int)
	size_t bad;
#endif
	int ccc;


(etc) - with similar noise for time_t, ptrdiff_t, long, long long,
float, double, long double, intmax_t, every different struct that is
used, and all the arrays, and different pointer types.  (And up there,
I didn't cover all the possibilities, like sizeof(char) == sizeof(short)
which would mean a different order, and either of those being == sizeof(int)
which would be yet another order).

The style guide says to sort by size (not type) and then for vars of the
same size, alpha by name.

You really do that?    Where?   I have to look at that code!

kre



Home | Main Index | Thread Index | Old Index