lua-users home
lua-l archive

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


On Tue, Oct 03, 2006 at 09:27:22PM -0700, David Haley wrote:
> I was unable to compile lposix.c because CLK_TCK was not defined.

You are trying to compile posix code with the -ansi flag, aren't you?

lposix.c requires POSIX features, so specifying "-ansi" to gcc
isn't a great idea.

Look at "man 2 times" and at "man 3 sysconf" - if you really don't want
to use "obsolete POSIX symbols" (also known as "standard UNIX APIs"),
you need to use sysconf(_SC_CLK_TCK), CLOCKS_PER_SEC is not the same
value.

Cheers,
Sam

sroberts@pebble:/tmp% gcc -o ct -Wall -Werror ct.c && ./ct
CLK_TCK 100
CLOCKS_PER_SEC 1000000
_SC_CLK_TCK 100
sroberts@pebble:/tmp% cat ct.c
#include <stdio.h>
#include <time.h>
#include <unistd.h>

int main()
{
        printf("CLK_TCK %lu\n", CLK_TCK);
        printf("CLOCKS_PER_SEC %lu\n", CLOCKS_PER_SEC);
        printf("_SC_CLK_TCK %ld\n", sysconf(_SC_CLK_TCK));
        return 0;
}

sroberts@pebble:/tmp% gcc --version
gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
sroberts@pebble:/tmp% uname -a
Linux pebble.bycast.com 2.6.15-27-386 #1 PREEMPT Sat Sep 16 01:51:59 UTC 2006 i686 GNU/Linux