[Info-vax] Color me confused (VMS C issues, this time with %zu)
John Reagan
xyzzy1959 at gmail.com
Wed Oct 26 08:19:29 EDT 2016
On Wednesday, October 26, 2016 at 3:41:13 AM UTC-4, Richard Levitte wrote:
> I'm a little confused... The VMS C manual [1] states that:
>
> -----8<-----
> It also provides complete language support for ISO/IEC 9899:1999, informally called C99, although not all run-time library routines are currently implemented, floating-point environment access controls are not effective, and Annex F (the optional __STDC_IEC_559__ extension) is not supported.
> -----8<-----
>
> And sure enough, __STDC_VERSION__ is 199901L.
>
> And yet, this fails to run properly:
>
> -----8<-----
> #include <stdio.h>
>
> #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
> # define zu "zu"
> #else
> # define zu "llu"
> #endif
>
> int main()
> {
> size_t foo = 1;
>
> printf("__STDC_VERSION__ is %lu\n", __STDC_VERSION__);
> printf("zu is '%s'\n", zu);
> printf("foo is %" zu "\n", foo);
> }
> -----8<-----
>
> See this session:
>
> -----8<-----
> $ cc/version
> HP C V7.3-018 on OpenVMS IA64 V8.4
> $ cc foo.c
>
> printf("foo is %" zu "\n", foo);
> ...............................^
> %CC-W-UNSUPCONVSPEC, In this statement, this argument to printf has a conversion
> specification "%zu" that is not supported or not fully supported on this platfo
> rm.
> at line number 15 in file PROGRAM:[LEVITTE-BUILDS.OPENSSL-EXPERIMENTAL.IA64]FOO.
> C;4
> $ link foo
> %ILINK-W-COMPWARN, compilation warnings
> module: FOO
> file: PROGRAM:[LEVITTE-BUILDS.OPENSSL-EXPERIMENTAL.IA64]FOO.OBJ;4
> $ run foo
> __STDC_VERSION__ is 199901
> zu is 'zu'
> foo is zu
> -----8<-----
>
> As far as I know, %zu isa C99 feature and not part of Annex F, so for a compiler that "provides complete language support for ISO/IEC 9899:1999", this leads to fairly ackward preprocessor conditions specially for VMS.
>
> Or really, the the compiler doesn't provide complete language support for C99, should it pretend it does?
>
> Cheers,
> Richard
You are correct. Looking back, it should not have set that symbol.
We just added the support to the CRTL to bring it to C99 (the "z" and a few others; stdint.h; moving stuff around in inttypes.h, fp.h, float.h, and math.h) and it will soon be going to some form of field test. Interested? This is for VSI systems.
More information about the Info-vax
mailing list