Tru64 UNIXで遊ぼう!(C99編)
Tru64 UNIXでpkgsrcを動かそうと必死こいて作業していると、面白いエラーに遭遇しました。
よ〜やっとpkgsrc currentがTru64 UNIXで動くようになった...
— Lucky owner/capturer (@nullnilaki) 2017年6月24日
が、C99がまともにサポートされてないので
pkgsrc/security/netpgpverify/
でのコンパイルでコケるコケる...
どうやってPRしようかねぇ... pic.twitter.com/iUEvQI9Azi
libverify.c: In function 'fmt_time': libverify.c:678: warning: incompatible implicit declaration of built-in function 'llabs' libverify.c: In function 'read_ssh_file': libverify.c:2354: error: expected ')' before 'PRIi64' *** Error code 1
gcc -lssl -lcrypto -L/root/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/bzip2 -L/root/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/zlib -L/root/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/libarchive/.libs -L/root/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/libfetch -L/root/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/netpgpverify -L/root/pkgsrc/bootstrap/work/wrk/pkgtools/pkg_install/work/libnbcompat -L/usr/lib -Wl,-R/usr/lib -Wl,-R/root/pkgsrc/bootstrap/pkg/lib -L../lib -o pkg_add main.o perform.o -linstall -lnetpgpverify -larchive -lbz2 -lz -lfetch -lssl -lcrypto -lcrypto -lbz2 -lz -lnbcompat -lnbcompat strtoull collect2: ld returned 1 exit status *** [pkg_add] Error code 1
あれ? Tru64 UNIXのCompaq CはC99に対応しているはず...
下記マニュアルにも
Compaq C Version 6.4 provides most of the language-feature support for the new C99 standard
と書いてあります
しかし、リンカがエラーを吐いているという事は、ライブラリがstrtoullをサポートしていないとしか考えられない?
というわけでCompaq Cのリリースノートを見てみました!
すると衝撃的な事が...
6.1 New C99 library functions The Compac C compiler kit ships system header files that declare new ANSI/ISO C99 library names such as round, roundf, and roundl (math.h). The C99 header files install into /usr/include.dtk. This directory is added to the compiler's #include search path automatically by the cc driver so that the header files will be read during "normal" compiles. The header files declare ALL of the new C99 names even though many of those functions do not yet exist in the libraries of shipping versions of Tru64 UNIX. The names are reserved by the C99 Standard and the library functions will become available in future versions of the OS.
工エエエエエエェェェェェェ(゚Д゚)ェェェェェェエエエエエエ工工工
ヘッダファイルはC99に対応したけど、ライブラリは対応してないだと...
C99用の/usr/include.dtk/inttypes.hを見ると
$ more /usr/include.dtk/inttypes.h /* * ***************************************************************** * * * * * Copyright 2001 Compaq Computer Corporation * * * * ... /* begin - fprintf macros for signed integers */ #define PRId8 "d" #define PRId16 "d" #define PRId32 "d" #define PRId64 "ld" ...
なので
#include <stdio.h> #include <inttypes.h> #include <stdlib.h> int main(void) { int64_t data = 12345; printf("data=%"PRId64"\n",data); return EXIT_SUCCESS; } gccは対応していない... (/usr/include.dtkを見に行かないので...) $ /usr/local/bin/gcc meso.c meso.c: In function 'main': meso.c:10: error: expected ')' before 'PRId64' Compaq Cは対応している (/usr/include.dtkを見に行く) $ cc meso.c $ ./a.out data=12345
または、C99用の/usr/include.dtk/stdlib.hを見ると
$ more /usr/include.dtk/stdlib.h /* * ******************************************************************************** * * * * * Copyright 2002 Compaq Information Technologies Group, L.P. * ... extern unsigned long long int strtoull( const char * /*restrict*/ __nptr, char ** /*restrict*/ __endptr, int __base); ....
なので
#include <stdio.h> #include <stdlib.h> #define BASE 0 int main(void) { char *string, *stopstring; unsigned long long x; string = "255"; printf("string = %s\n", string); x = strtoull(string, &stopstring, BASE); printf("strtoull = %llu \n", x); return EXIT_SUCCESS; } gccもCompaq Cもリンカがエラーを出力 $ /usr/local/bin/gcc foo.c strtoll collect2: ld returned 1 exit status $ cc foo.c ld: Unresolved: strtoll
2006年リリースのTru64 UNIX 5.1B-4でC99に対応していない状態で
2010年リリースのTru64 UNIX 5.1B-6が最終リリースなので
Tru64 UNIXはC99に対応していない、がファイナルアンサーという事なんでしょうかねぇ?
教えて、教えてエロイ人
____________ ヾミ || || || || || || || ,l,,l,,l 川〃彡| V~~''-山┴''''""~ ヾニニ彡| C99に対応したライブラリを出す・・・・・・! / 二ー―''二 ヾニニ┤ 出すが・・・ <'-.,  ̄ ̄ _,,,..-‐、 〉ニニ| 今回 まだ その時と場所の /"''-ニ,‐l l`__ニ-‐'''""` /ニ二| 指定まではしていない | ===、! `=====、 l =lべ=| . | `ー゚‐'/ `ー‐゚―' l.=lへ|~| そのことを |`ー‐/ `ー―― H<,〉|=| どうか諸君らも | / 、 l|__ノー| 思い出していただきたい . | /`ー ~ ′ \ .|ヾ.ニ|ヽ |l 下王l王l王l王lヲ| | ヾ_,| \ つまり・・・・ . | ≡ | `l \__ 我々がその気になれば !、 _,,..-'′ /l | ~''' 対応は ‐''" ̄| `iー-..,,,_,,,,,....-‐'''" / | | 10年後 20年後ということも -―| |\ / | | 可能だろう・・・・・・・・・・ということ・・・・! | | \ / | |