lua-users home
lua-l archive

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


On Thu, Oct 05, 2006 at 11:46:56AM +0100, David Jones wrote:
> Indeed.  It would seem, from a bit of googling, that CLK_TCK went  
> (from the standards) a long time ago.  sysconf is a crucial  

"the standards"? X/Open defines CLK_TCK, warning that it might not be a
compile time constant (which it isn't on linux). The Single Unix
Specification, v2 also continues to define it, as far as I can tell.

And more importantly, nobody has posted here that *it doesn't work*.

> cornerstone of POSIX, not an arcane interface.  Well, I suppose it  
> might be both. :)

Guys, just because a new standard comes along, it doesn't mean that you
should change your code so it only works on new systems, or that all
the old code is suddenly "wrong"!

Notice how the lua source doesn't use "//"-style comments? Those are
ANSI C now, but when you build lua for some grotty cell phone with an
ancient C compiler, you will be thankful lua doesn't use //, even if it
is ANSI C.

> It was my understanding that most installations of GCC / glibc  
> allowed posix programs to compiler using -pedantic as long as the  
> posix programs were pedantically correct.  That is, they had a:
> 
> #define _POSIX_C_SOURCE 199209
> 
> declaration (or similar).  lposix.c should probably have one.  Good  
> luck choosing the right one.

YMMV, but defining _POSIX_C_SOURCE to 1 might get you access to the
system definitions from POSIX.1, which predates the removal of CLK_TCK.

This might work, too:

#ifdef _SC_CLK_TCK
#	define TICKS sysconf(_SC_CLK_TCK)
#else
#	define TICKS CLK_TCK
#endif


I don't agree with the "just use GCC extensions and ignore other
compilers" stance, but when using -pedantic and hoping it does something
useful, its worth remembering that the guys who implemented might not
care if it does anything useful for you. They aren't in the business of
making it easier for you to port to other compilers, so even though I
too wish there was an option to reject code that won't work everywhere,
the GCC team isn't going to build that option for us, and say as much in
their documentation.

Sam

p.s.

  Though some hasty zealots cry "not so; the Millenium is come, and this
  saying is obsolete and no longer need be supported", verily there be
  many, many ancient systems in the world, and it is the decree of the
  dreaded god Murphy that thy next employment just might be on one.
  While thou sleepest, he plotteth against thee. Awake and take care.

	- The annotation to the 9th commandment for C programmers

Maybe your external identifiers can be longer than 6 characters, though :-)