using iargc()/getarg() form C

Satish Balay balay@fastmail.fm
Wed Feb 23 15:26:00 GMT 2005


On Wed, 23 Feb 2005, Steve Kargl wrote:

> On Wed, Feb 23, 2005 at 08:36:29AM -0600, Satish Balay wrote:
>> On Wed, 23 Feb 2005, Satish Balay wrote:
>>
>>>> This is crucial.  You must link the final program with the
>>>> gfortran command.
>>>
>>> Is this because of the automatic linking to -lgfortranbegin?  [we try
>>> to detect all compiler libraries - so that any compiler c/c++/fortran
>>> will work as the linker. sometimes this is messy and doesn't always
>>> work]
>>
>> Ah.. I should have said - we usually try to match the linker to the
>> language that has the entry point - aka main().
>>
>
> This is why you need to use gfortran.  Look at libgfortran/runtime/main.c.

This isn't an issue with gcc/g77/gfortran [coluld be with other compilers]
asterix:/home/balay/junk/arg>gcc4 -c arg.c
asterix:/home/balay/junk/arg>gfortran -c arg-test.f
asterix:/home/balay/junk/arg>gcc4 arg-test.o arg.o -L/usr/lib/gcc/i386-redhat-linux/4.0.0 -lgfortranbegin -lgfortranpreview
asterix:/home/balay/junk/arg>

But this is drifting elseware. The primary purpose I started this
thread is:

- If possible - have gfortran support iargc/iargv usage from C,
similar to gcc3 - this way curent codes don't break when distributions
upgrade from gcc3 to gcc4 [fedora is contemplating this move]. But
looks like internal library/symbol organization to support -i8 is
breaking this.

- if possible use command_argument_count() & get_command_argument() -
but with internal name trasformations - gfortran is requiring a
separete ifdef [in user code] anyway - so not much benifit here.

Satish



More information about the Fortran mailing list