(j3.2006) Get_Command_Argument

Van Snyder van.snyder
Fri Dec 16 03:42:43 EST 2011


Malcolm Cohen wrote:
>> What translation?  C_char to c_char?
>>     
>
> The translations I pointed out in my previous message.
>
> I know some like to think the whole world could make do with ASCII, but that is not the case.  The "real" command line is not necessarily going to be C char, and that means translation if you want a C char version.
>
> You seem to think we know what translation you want and so "it will just work 20 years from now".  It just ain't so.
>   

I'm assuming that if get_command_argument(i,value) were to provide the 
VALUE argument as a kind c_char variable, it would be the same that a C 
main function would get from argv[i].  If that's actually naive, then I 
guess I'll need more explanation why there would be translations 
involved, for which my programs would be responsible.

I don't have a C standard at hand, but my K&R book, on page 115, defines 
argv as

  char* argv[]

Could a C programmer safely assume that argv[] is "char*"?

Could a Fortran programmer safely assume that C type "char" is 
equivalent to Fortran type CHARACTER(kind=c_char)?

If those assumptions are both safe, what's the problem with allowing 
get_command_argument to return a VALUE argument of kind c_char, at least 
allowing one to pass it along to a C function that expects the same 
value it would have gotten from its own main function's argv?

Does the current C standard actually define argv with a type different 
from char?  If so, the Fortran standard ought to provide a kind, in 
ISO_C_Binding, that's equivalent, and allow get_command_argument to 
return a VALUE with that kind.

> Cheers,
>   




More information about the J3 mailing list