....edu> wrote: Raúl wrote: integer(c_int), bind(c,name='errno') :: errno It is probably best to call a C routine that returns errno. I believe that it is commonly an ordinary externalvariable, but there are other possibilities. As an aside (since I think the problem and ... much of anything to do with being in a library as the OP thought. Instead, it is specific to...
....edu> writes: Raúl wrote: integer(c_int), bind(c,name='errno') :: errno It is probably best to ... a C routine that returns errno. I believe that it is commonly an ordinary externalvariable, but there are other possibilities. From FreeBSD /usr/include/errno.h, #ifndef ... errno is not required to be an int variable. It is required to be a modifable lvalue....
Raúl wrote: integer(c_int), bind(c,name='errno') :: errno It is probably best to call a C routine that returns errno. I believe that it is commonly an ordinary externalvariable, but there are other possibilities. -- glen
... to read an externalvariable which is declared in an externallibrary, in... status in the well known errno variable of libc. Checking Fortran forums I ... module test  use iso_c_binding  integer(c_int), bind(c,name='errno') :: errno  ...  ... end module ... It may be that this particular variable is not visible (exported) outside the library. I am not sure of that...
...to read an externalvariable which is declared in an externallibrary, ... in the well known errno variable of libc. Checking Fortran forums I...such thing I have to use bind modifier in my declaration of the variable. The code is as follows ... test use iso_c_binding integer(c_int), bind(c,name='errno') :: errno ... ... end ... be because is a dynamic library and not a static one....
... PL/I functions without arguments also did not have the (). Later they were added because of the complications due to adding new functions to the language. (Conflicting with variable names in older programs.) It always seemed right for random number generators, which I suppose are pretty unmathematical as functions. Random number generators are already the one case where...
...> And furthermore, a function without arguments is so, well, unmathematical :). or "win32ish" Regards, Arjen -- Gary Scott mailto:garylscott@sbcglobal dot net Fortran Library: http://www.fortranlib.com Support the Original G95 Project: http://www.g95.org -OR- Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html If you want to do ...
... do this in C. In fortran at least according to MR&C volatile can only be applied to variables Ian Thanks to everybody for your suggestions. I suppose that is not a problem of externallibrary. It should be a problem of using a bad symbol name. I tried your two solution and they work fine. But finally I ...
... is so, well, unmathematical :). In the original PL/I functions without arguments also did not have the (). Later they were added because of the complications due to adding new functions to the language. (Conflicting with variable names in older programs.) It always seemed right for random number generators, which I suppose are pretty unmathematical as functions. -- glen
.... Maybe volatile int get_errno() { return errno; ? No idea if you can do this in C. In fortran at least according to MR&C volatile can only be applied to variables As far as I know, C never optimizes away such calls. Note that C only has functions, no subroutines. There are no ELEMENTAL or PURE functions in C. One of the more common argumentless functions (...