lua-users home
lua-l archive

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


On this day of 10/04/2006 09:52 AM, Sam Roberts saw fit to scribe:
> 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.
>   

Actually, no; I was using LHF's Makefile which uses these arguments for
compilation:

gcc -fPIC -I/usr/local/lua-5.0.2/include -pedantic -Wall -O2 -c -o
lposix.o lposix.c

no -ansi there.

> 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.
>   


When I compile your program, I get this:

[david@binarygoblin posix]$ gcc -o ct -Wall -Werror ct.c && ./ct
ct.c: In function ‘main’:
ct.c:7: error: ‘CLK_TCK’ undeclared (first use in this function)
ct.c:7: error: (Each undeclared identifier is reported only once
ct.c:7: error: for each function it appears in.)


Here is my system information:

[david@binarygoblin posix]$ gcc --version
gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)

[david@binarygoblin posix]$ uname -a
Linux binarygoblin.stanford.edu 2.6.16-1.2096_FC5 #1 Wed Apr 19 05:14:36
EDT 2006 i686 i686 i386 GNU/Linux



Interestingly enough when I compile on a Ubuntu system it works fine.
(The gcc version and distro is the same as yours so there's not much
surprise, I suppose...)

[david@thebalrog:~]$ gcc --version
gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5)

[david@thebalrog:~]$ uname -a
Linux thebalrog 2.6.15-27-amd64-k8 #1 SMP PREEMPT Sat Sep 16 01:57:42
UTC 2006 x86_64 GNU/Linux



It seems, in any case, that instead of defining CLK_TCK to be
CLOCKS_PER_SEC (which is what time.h seems to do?), the correct thing to
do would be to use sysconf(_SC_CLK_TCK) instead, right?

Best,
- David

-- 
~David-Haley
http://david.the-haleys.org