Re: Can Fortran Use This C Variable Directly Via "external" Decl?



clusardi2k@xxxxxxx wrote:

I'm pretty sure this is impossible, but someone
> suggested it to me.

Can I do this with the f77 compiler:

/** main.C **/

int try_it;

int test_ ()
{
}

CCC  test.F   CCC
       program main
       external try_it
       try_it = 100
       stop
       end

I am not sure what you are trying to do.

test_() doesn't ever get called.
I don't know what happens when you have a variable the same
name as as external statement.

It is usual for C static external variables, declared outside any
functions with or without the extern keyword and without the static
keyword, to be allocated in the same way as Fortran COMMON.
A COMMON with more than one variable should agree with a C static external struct, except for alignment issues.


-- glen

.



Relevant Pages

  • Re: Use of extern keyword
    ... > i.e consider a following piece of code from MSDN explaining extern ... > void next ... > Here,if I drop the extern keyword from source file 2 and compile and ... in using global variables, it's much better practice to define the ...
    (comp.lang.c)
  • Re: The proper use of the extern keyword
    ... >the extern keyword. ... >Now I thought that I needed to use it when I hade two .cpp files in the same ... >So when is the extern keyword actually used? ... Non-member function declarations not declared with the "static" keyword ...
    (alt.comp.lang.learn.c-cpp)
  • Re: extern
    ... >>>Possibly because the standard talks about linkage and the extern keyword ... an external linkage declarator. ... > referenced, and in any case extern is a keyword with specific meaning, ...
    (comp.lang.c)
  • Re: Calling C++ from C
    ... I think you can mix and match C and C++ in the same project, the extern keyword is when you need to do external linkage and need a calling convention. ... the IDE will invoke compilers slightly differently depending on whether you have an *.c or *.cpp file extension on the source file. ...
    (microsoft.public.vsnet.general)
  • Re: extern
    ... >> 6.2.2p4 fully defines the meaning of the extern keyword, ... >> declaration with the extern keyword does not reverse the original ... Declared extern usually implies external linkage, ...
    (comp.lang.c)