473,320 Members | 1,839 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,320 software developers and data experts.

filling static vars from different file

Hi,

I'm looking for a way to fill static vars from a different c-file.

Here is what I want to do:

file1.c
static DEBUG
calling function X using DEBUG to display information
calling function Y using DEBUG to display information

file2.c
static DEBUG
calling function X using DEBUG to display information
calling function Y using DEBUG to display information

main.c
load and reload ini file to set DEBUG for file1.c to true and for
file2.c to false
This is a existing system which I'm profiling to optimize the system
so I'm limited in the way of changing things. Right now the main.c
reads all ini files into a balanced tree and function X parses the
tree to check the values.

Filling static vars is just one method I'm thinking about.

Is there a way to execute a function once per source file (this could
set the var)..

Anyone have a suggestion ??

Kind regards,
Ronald
Apr 6 '06 #1
2 1356

r.*****@mtel.nl wrote:
Hi,

I'm looking for a way to fill static vars from a different c-file.

Here is what I want to do:

file1.c
static DEBUG
calling function X using DEBUG to display information
calling function Y using DEBUG to display information

file2.c
static DEBUG
calling function X using DEBUG to display information
calling function Y using DEBUG to display information

main.c
load and reload ini file to set DEBUG for file1.c to true and for
file2.c to false
This is a existing system which I'm profiling to optimize the system
so I'm limited in the way of changing things. Right now the main.c
reads all ini files into a balanced tree and function X parses the
tree to check the values.

Filling static vars is just one method I'm thinking about.

Is there a way to execute a function once per source file (this could
set the var)..

Anyone have a suggestion ??

Kind regards,
Ronald


file1.c
----------------
static int abc,foo,bar,

void initfile1vars(void)
{
abc=0xDEADBEEF;
foo=0xBEADFACE;
bar=0x69696969;
}
file2.c
----------
initfile1vars();
you could also pass in values from file1 if you like, or a pointer to
values...

Apr 6 '06 #2
On 6 Apr 2006 08:17:49 -0700, "Ivanna Pee" <fr***@Infectedmail.com>
wrote:

Made something like this, it works, thanx...

file1.c
----------------
static int abc,foo,bar,

void initfile1vars(void)
{
abc=0xDEADBEEF;
foo=0xBEADFACE;
bar=0x69696969;
}
file2.c
----------
initfile1vars();
you could also pass in values from file1 if you like, or a pointer to
values...

Apr 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: flamesrock | last post by:
ok, so to my knowledge, object oriented means splitting something into the simplest number of parts and going from there. But the question is- when is it enough? For example I have the following...
0
by: David Boaz | last post by:
Hello all, I have an middleware that has to be accessed from two different applications, win-form and asp-form. the middleware uses a file to store and retrieve information. I want to economize...
5
by: Marijn | last post by:
I'd like to know how compilers usually handle static variables that are declared inside a function (as opposed to static class-members). Like in: int counter(){ static int c=0; ++c; return c;...
9
by: vp | last post by:
Can I safely assume that all static variables are initialized as NULL or zero, depending on the types of the variables, no matter on which platform that app is compiled ? Thanks for your help, ...
6
by: GG | last post by:
Is this public static method thread safe. //Receives a file name as a parameter //and returns the contents of that file as a string public static string FileToStr(string fileName) { FileStream...
10
by: John A Grandy | last post by:
Say I have Class1 which contains static Class2 var1 = new Class2(); Is Class2 constructor code only executed if var1 is referenced in the code-execution path ? Or is Class2 constructor code...
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...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.