473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

is static storage duration enforced if C is called from a different language?

I'm in the process of updating a medium-sized Fortran program. I've just finished replacing the random number generator, which is now written in C. The C source code uses variables with "static storage duration" (which some people like to call global variables) to store that state of the random number generator between calls.

If the entire program is written in C, this means (using non-C-expert terminology) that when the program is compiled, there is some mechanism in place to prevent the memory from being freed up and overwritten by other parts of the program. However, what happens if the rest of the program is written in a different language? Can we still say that we are guaranteed that the memory will not be freed up between calls to the random number generator?

The C source files of course will be compiled to object, the Fortran files will be compiled to object files, and the object files will be linked to create the executable. I was always taught that there really isn't a "C linker" and a "Fortran linker", but just an object file linker. This line of reasoning suggests that whatever mechanism is used enforce the C storage duration will be preserved in the executable, regardless of what language the rest of the program is written in. However, I cannot say this with any authority. Can someone comment on this?
Nov 3 '09 #1
1 1796
donbock
2,426 Expert 2GB
Either you have a C run-time environment or you don't. If you have a C run-time environment then the variables with static storage duration will work the way you expect. If you don't have a C run-time environment then so many things will go wrong that you won't notice the storage duration of those variables.
Nov 3 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: A | last post by:
Hi, Consider this code: //Header File - Foo.h int i = 0; // non-static global variable class Foo{ ...
5
by: Luther Baker | last post by:
Hi, Is the order of initialization guaranteed for static members as it is for instance members? Namely, the order they appear the in the declaration? ie: foo.h:
8
by: Scott J. McCaughrin | last post by:
The following program compiles fine but elicits this message from the linker: "undefined reference to VarArray::funct" and thus fails. It seems to behave as if the static data-member:...
115
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical...
33
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or...
18
by: Ronald Bruck | last post by:
I have several routines which are used millions of times in my programs, using the Gnu multi-precision software's floating-point reals (see <http://www.swox.se/gmp>). These are of type mpf_t, and...
6
by: asit | last post by:
Static variables can't be initialized with functions, becoz these are load time processes. Why this is so ?? What is a load time process ??
1
by: christian.bau | last post by:
On Oct 9, 6:49 pm, regis <regis.barbanc...@free.frwrote: C99 Standard draft 6.7.4.3: "An inline definition of a function with external linkage shall not contain a definition of a modifiable...
2
by: chenxinleo | last post by:
Hi, When i use some standard library functions and fields,which return char* type(like ctime in time.h, optarg in getopt.h)and do not have to be freed after calling,i always worry about memory...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.