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

Strange global variable behavior

Hello,

I have a problem using some global variables which are an array[4] of a
structure and an array[4] and some other structures.
Those variables are set to some values then program call a function
(void foo(void)).
When I step into the function, all fields of all variable are reset

Here is some debug information.

389: foo();
00404EBB call uplarstr_Average (00401000)

-> Here is the reset of the variables

292: void foo ( void )
293: {
00401000 push ebp
00401001 mov ebp,esp
00401003 sub esp,78h
00401006 push ebx
00401007 push esi
00401008 push edi
00401009 lea edi,[ebp-78h]
0040100C mov ecx,1Eh
00401011 mov eax,0CCCCCCCCh
00401016 rep stos dword ptr [edi]
00401018 push offset _atc_data1 (0041b030)
0040101D call _atc_link (00408a10)
00401022 add esp,4
00401025 mov byte ptr [_atc_proc1+2 (0041be3e)],1
0040102C mov byte ptr [_atc_bloc1+26h (0041bd36)],1

Thank you,
Romain

--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com

Nov 14 '05 #1
8 1023
Romain <ro****************@spam.free.fr> spoke thus:
I have a problem using some global variables which are an array[4] of a
structure and an array[4] and some other structures.
Those variables are set to some values then program call a function
(void foo(void)).
When I step into the function, all fields of all variable are reset Here is some debug information.


Debug information is not what we want. What we *do* want is code that
demonstrates your problem - we can help you fix it.

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #2
Which part of "comp.lang.c" was too difficult for you to understand?

Dan

In <me*******************************@spam.free.fr> Romain <ro****************@spam.free.fr> writes:
Hello,

I have a problem using some global variables which are an array[4] of a
structure and an array[4] and some other structures.
Those variables are set to some values then program call a function
(void foo(void)).
When I step into the function, all fields of all variable are reset

Here is some debug information.

389: foo();
00404EBB call uplarstr_Average (00401000)

-> Here is the reset of the variables

292: void foo ( void )
293: {
00401000 push ebp
00401001 mov ebp,esp
00401003 sub esp,78h
00401006 push ebx
00401007 push esi
00401008 push edi
00401009 lea edi,[ebp-78h]
0040100C mov ecx,1Eh
00401011 mov eax,0CCCCCCCCh
00401016 rep stos dword ptr [edi]
00401018 push offset _atc_data1 (0041b030)
0040101D call _atc_link (00408a10)
00401022 add esp,4
00401025 mov byte ptr [_atc_proc1+2 (0041be3e)],1
0040102C mov byte ptr [_atc_bloc1+26h (0041bd36)],1

--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #3
This IS C language with assembly code from the debugger !!!
But problem problem is solved !! (and it was a C problem !!!)
Thank you for your "help"!

Dan Pop avait énoncé :
Which part of "comp.lang.c" was too difficult for you to understand?

Dan


--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com

Nov 14 '05 #4
In <me*******************************@spam.free.fr> Romain <ro****************@spam.free.fr> writes:
This IS C language with assembly code from the debugger !!!
I haven't noticed the C language part (and neither did other people
replying to your post) and the assembly code from the debugger has
exactly zilch to do with the C programming language, the topic of this
newsgroup.
But problem problem is solved !! (and it was a C problem !!!) ^^^^^^^^^^^^^^^^^^^^^^
No one doubted it. It's just that your original post failed to describe
it.
Thank you for your "help"!


Before being sarcastic, make sure that you're right! Otherwise, your
sarcasm will backfire.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #5
Romain <ro****************@spam.free.fr> scribbled the following:
This IS C language with assembly code from the debugger !!!
But problem problem is solved !! (and it was a C problem !!!)
Thank you for your "help"!


It is considered good behaviour, when reporting that a problem was
solved, to also report *how* it was solved. This helps people who
might have had the same problem.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I am lying."
- Anon
Nov 14 '05 #6
Sorry everybody,
actually the problem was I haven't noticed that global variables were
'static' due to an unexplicit macro in declaration. So I was actually
using 2 different global variables with the same name.

Bye,
Romain
Joona I Palaste a émis l'idée suivante :
Romain <ro****************@spam.free.fr> scribbled the following:
This IS C language with assembly code from the debugger !!!
But problem problem is solved !! (and it was a C problem !!!)
Thank you for your "help"!


It is considered good behaviour, when reporting that a problem was
solved, to also report *how* it was solved. This helps people who
might have had the same problem.


--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com

Nov 14 '05 #7
Romain wrote:

Sorry everybody,
actually the problem was I haven't noticed that global variables
were 'static' due to an unexplicit macro in declaration. So I was
actually using 2 different global variables with the same name.


Please don't toppost. The above shows that the assembly code was
nothing but a distraction, and you should simply have posted a
minimal compilable source that exhibited the problem, as advised
over and over and over and over here.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #8
On Wed, 14 Apr 2004 15:25:43 +0200, Romain
<ro****************@spam.free.fr> wrote:
This IS C language with assembly code from the debugger !!!
And you expected us to de-compile the assembler into the same C code
that you wrote? Dream on.
But problem problem is solved !! (and it was a C problem !!!)
Thank you for your "help"!

Dan Pop avait énoncé :
Which part of "comp.lang.c" was too difficult for you to understand?

Dan


--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #9

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

Similar topics

2
by: Kyle James Matthews | last post by:
I am working with the following script for a weblog that manipulates any combination of two variables: $postauthor and $archive. if (isset($HTTP_GET_VARS)) { $archive = $HTTP_GET_VARS; if...
8
by: Romain | last post by:
Hello, I have a problem using some global variables which are an array of a structure and an array and some other structures. Those variables are set to some values then program call a function...
7
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
6
by: MechSoft | last post by:
Hi, I am new to C++ from C, I am a bit confused about using global objects in C++. I have a program that need to share some data(held in classes) between files, and of course I thought about using...
1
by: Larax | last post by:
Alright, so here's the problem. I define a global variable in my script and then add methods/properties to it. Everything works great, no error in Javascript Console. But when I refresh site,...
5
by: IloChab | last post by:
Sorry I wasn't able to be more specific on my topic but I really do not know how to classify my problem, I mean that I can't understand if it's a python or a twisted or a Qt4 problem I'm...
8
by: FBM | last post by:
Hi there, I am puzzled with the behavior of my code.. I am working on a networking stuff, and debugging with eclipse (GNU gdb 6.6-debian).. The problem I am experiencing is the following: ...
2
by: Andy Carlson | last post by:
I have a strange problem. I am trying to use a global variable, but I can't get the second routine to recognize changes to the globabl. I finally realize, that I was forking, so the global was...
8
by: yinglcs | last post by:
Hi, I read this article about global variable in c: http://www.phim.unibe.ch/comp_doc/c_manual/C/SYNTAX/glo_int_vars.html But I have a few questions 1. how can I declare the global variable...
1
by: viraj.kadakia | last post by:
I observe a behavior with shared libraries (.so) and global variables that I cannot understand ... I'd appreciate if someone can explain the behavior .. Scenario 1: aTest is an executable on...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.