Connecting Tech Pros Worldwide Forums | Help | Site Map

Strange global variable behavior

Romain
Guest
 
Posts: n/a
#1: Nov 14 '05
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


Christopher Benson-Manica
Guest
 
Posts: n/a
#2: Nov 14 '05

re: Strange global variable behavior


Romain <romainveillerot.no@spam.free.fr> spoke thus:
[color=blue]
> 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[/color]
[color=blue]
> Here is some debug information.[/color]

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.
Dan Pop
Guest
 
Posts: n/a
#3: Nov 14 '05

re: Strange global variable behavior


Which part of "comp.lang.c" was too difficult for you to understand?

Dan

In <mesnews.72cb7d44.2146a2e7.1.10868@spam.free.fr> Romain <romainveillerot.no@spam.free.fr> writes:
[color=blue]
>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[/color]
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
Romain
Guest
 
Posts: n/a
#4: Nov 14 '05

re: Strange global variable behavior


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é :[color=blue]
> Which part of "comp.lang.c" was too difficult for you to understand?
>
> Dan[/color]

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

Dan Pop
Guest
 
Posts: n/a
#5: Nov 14 '05

re: Strange global variable behavior


In <mesnews.739d7d44.407ea97e.2.10868@spam.free.fr> Romain <romainveillerot.no@spam.free.fr> writes:
[color=blue]
>This IS C language with assembly code from the debugger !!![/color]

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.
[color=blue]
>But problem problem is solved !! (and it was a C problem !!!)[/color]
^^^^^^^^^^^^^^^^^^^^^^
No one doubted it. It's just that your original post failed to describe
it.
[color=blue]
>Thank you for your "help"![/color]

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

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de
Joona I Palaste
Guest
 
Posts: n/a
#6: Nov 14 '05

re: Strange global variable behavior


Romain <romainveillerot.no@spam.free.fr> scribbled the following:[color=blue]
> 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"![/color]

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 (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I am lying."
- Anon
Romain
Guest
 
Posts: n/a
#7: Nov 14 '05

re: Strange global variable behavior


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 :[color=blue]
> Romain <romainveillerot.no@spam.free.fr> scribbled the following:[color=green]
>> 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"![/color]
>
> 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.[/color]

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

CBFalconer
Guest
 
Posts: n/a
#8: Nov 14 '05

re: Strange global variable behavior


Romain wrote:[color=blue]
>
> 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.[/color]

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 (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


Alan Balmer
Guest
 
Posts: n/a
#9: Nov 14 '05

re: Strange global variable behavior


On Wed, 14 Apr 2004 15:25:43 +0200, Romain
<romainveillerot.no@spam.free.fr> wrote:
[color=blue]
>This IS C language with assembly code from the debugger !!![/color]

And you expected us to de-compile the assembler into the same C code
that you wrote? Dream on.
[color=blue]
>But problem problem is solved !! (and it was a C problem !!!)
>Thank you for your "help"!
>
>Dan Pop avait énoncé :[color=green]
>> Which part of "comp.lang.c" was too difficult for you to understand?
>>
>> Dan[/color][/color]

--
Al Balmer
Balmer Consulting
removebalmerconsultingthis@att.net
Closed Thread


Similar C / C++ bytes