mdolidon/endlines

(OSX) CLOCK_REALTIME undeclared

Closed this issue · 4 comments

Building on a mac:

Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I get:

cc -O3 -Wall -std=c99 -c src/file_operations.c -o src/file_operations.o
cc -O3 -Wall -std=c99 -c src/walkers.c -o src/walkers.o
cc -O3 -Wall -std=c99 -c src/convert_stream.c -o src/convert_stream.o
cc -O3 -Wall -std=c99 -c src/main.c -o src/main.o
src/main.c:251:5: warning: implicit declaration of function 'clock_gettime' is invalid in C99 [-Wimplicit-function-declaration]
    clock_gettime(CLOCK_REALTIME, &res);
    ^
src/main.c:251:19: error: use of undeclared identifier 'CLOCK_REALTIME'
    clock_gettime(CLOCK_REALTIME, &res);
                  ^
1 warning and 1 error generated.
make: *** [src/main.o] Error 1

Great. I'll try the fix tomorrow. However, as I said, as I don't have a Mac anymore, would you be OK to test the fix and give away the binary ?

In the meanwhile you can use version 1.7 that works just the same and does not use the real time clock. The only difference is you don't want to run several instances 1.7 concurrently at the very same instant over one given folder. An OSX binary 1.7 is available (compiled on 10.7) : https://github.com/mdolidon/endlines/blob/master/binaries/endlines-1.7-osx

@EthicalBanker
Hello. I've reopened the dev branch. Please feel free check whether this compiles better on OSX.

git pull origin dev
git checkout dev
make

If so, I'll appreciate if you also agree to provide the resulting binary (a pull request should do), that I'll then merge into the master branch with the relevant bookkeeping.

Instead of fixing the real time clock to compile on OSX's peculiarities, I've changed the method of producing a unique temporary file name, and use the process's PID instead. It's a better way anyway. :)

Not getting any response, and being unable to verify by myself on OSX, but given that I checked Apple's docs thoroughly, I assume that the fix will work, I merge dev into master and I close this issue.