Variable number of arguments
- From: salgerman@xxxxxxxxx
- Date: 22 Feb 2007 08:11:12 -0800
I have about 100 fortran-77 programs that I need to enhance in a
certain way. To accomplish such task, I thought implementing a C
function with variable number of arguments would allow me to do what I
need.
I have implemented the entire functionality and it works in MinGW and
in Solaris, but it does not work in Linux, and I do need it to work
there, too!
As I started to take commands out for debugging purposes, I ended up
discovering that it is just not letting me do "variable number of
arguments" in the first place...but just Linux! Otherwise this
minimal program and my full version they both work just fine in MinGW
and Solaris.
%%%%%%%%%%%%%%%%%%%%%%%%%%%
Here are my platforms
My Dell D600 Windows XP with MinGW "Intel-inside" Box.
MINGW32_NT-5.1 W72C-CGFJN41 1.0.11(0.46/3/2) 2004-04-30 18:55
i686 unknown
My Solaris sparc Box:
SunOS pillbox 5.9 Generic_118558-24 sun4u sparc SUNW,Sun-
Blade-1500
My Red Hat Linux AMD Box:
Linux egret 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:24:31 EDT
2006 x86_64 x86_64 x86_64 GNU/Linux
%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Here is my C function with variable number of arguments: prog.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
//void c_function(const char *fmt) // this works
void c_function(const char *fmt,...) // this does not
{
printf("Inside c_function, fmt = %s\n", fmt);
return;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
c Here is my fortran 77 program calling the C function: test.f
program main
character nl
nl = char(0)
call c_function('The %s is '//nl)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%
Here is how I compile:
gcc -c prog.c
g95 -c -fno-underscoring test.f
g95 -o test test.o prog.o
Does anybody have any idea what the problem could be? and its
solution?
Thanks in advance for any pointers.
gsal
.
- Follow-Ups:
- Re: Variable number of arguments
- From: Colin Watters
- Re: Variable number of arguments
- From: glen herrmannsfeldt
- Re: Variable number of arguments
- From: Richard Maine
- Re: Variable number of arguments
- Prev by Date: Re: reading lines with trailing white spaces
- Next by Date: RE: reading lines with trailing white spaces
- Previous by thread: About generating random numbers under Unix using Fortran90
- Next by thread: Re: Variable number of arguments
- Index(es):