I get the following with VSI C X7.4-726 (GEM 50x23) on OpenVMS x86_64 E9.2-1
$ ty test.c
#include <varargs.h>
main()
{
va_list ap;
va_start( ap );
}
1-MAY-2023 10:33:59
$ cc test.c
va_start( ap );
...^
%CC-E-UNDECLARED, In this statement, "va_alist" is not declared.
at line number 5 in file $DISK0:[JOUKJ.test]TEST.C;4
A bug or do I mjss something?
Jouk
Problems with va_start on X86_64
-
- Master
- Posts: 335
- Joined: Fri Apr 17, 2020 7:31 pm
- Reputation: 0
- Location: Rhode Island, USA
- Status: Offline
- Contact:
Re: Problems with va_start on X86_64
varargs.h should either work or give a "not supported anymore" type of error.
But stdarg.h has been the standard since C89 (34 years), so recommending it certainly makes sense.
But stdarg.h has been the standard since C89 (34 years), so recommending it certainly makes sense.
Re: Problems with va_start on X86_64
However "help crtl va_start" gives varargs.h as header.
Changing to stdarg.h seems to help me.
thanks
Jouk
Changing to stdarg.h seems to help me.
thanks
Jouk
-
- Master
- Posts: 335
- Joined: Fri Apr 17, 2020 7:31 pm
- Reputation: 0
- Location: Rhode Island, USA
- Status: Offline
- Contact:
Re: Problems with va_start on X86_64
I get the exact same error on VMS Alpha with that code.
$ typ z.c
#include <varargs.h>
int main()
{
va_list ap;
va_start( ap );
return 0;
}
$ cc z
va_start( ap );
....^
%CC-E-UNDECLARED, In this statement, "va_alist" is not declared.
at line number 6 in file DISK2:[ARNE]z.c;5
Added in 11 minutes 15 seconds:
There seems to be certain differences between varargs.h and stdarg.h usage:
$ typ z.c
#include <varargs.h>
int main()
{
va_list ap;
va_start( ap );
return 0;
}
$ cc z
va_start( ap );
....^
%CC-E-UNDECLARED, In this statement, "va_alist" is not declared.
at line number 6 in file DISK2:[ARNE]z.c;5
Added in 11 minutes 15 seconds:
There seems to be certain differences between varargs.h and stdarg.h usage:
Code: Select all
$ type va1.c
#include <stdio.h>
#include <stdarg.h>
void test(int n, ...)
{
int i;
va_list ap;
va_start(ap, n);
for(i = 0; i < n; i++)
{
printf("%d : %s\n", i, va_arg(ap, char *));
}
va_end(ap);
}
int main(int argc, char *argv[])
{
test(1, "A");
test(2, "A", "BB");
test(3, "A", "BB", "CCC");
return 0;
}
$ cc va1
$ link va1
$ run va1
0 : A
0 : A
1 : BB
0 : A
1 : BB
2 : CCC
$ type va2.c
#include <stdio.h>
#include <varargs.h>
void test(n, va_alist)
int n;
va_dcl
{
int i;
va_list ap;
va_start(ap);
for(i = 0; i < n; i++)
{
printf("%d : %s\n", i, va_arg(ap, char *));
}
va_end(ap);
}
int main(int argc, char *argv[])
{
test(1, "A");
test(2, "A", "BB");
test(3, "A", "BB", "CCC");
return 0;
}
$ cc va2
$ link va2
$ run va2
0 : A
0 : A
1 : BB
0 : A
1 : BB
2 : CCC