Strange global variable behavior

R

Romain

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
 
C

Christopher Benson-Manica

Romain said:
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
 
D

Dan Pop

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

Dan

In said:
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
 
R

Romain

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é :
 
D

Dan Pop

In said:
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
 
J

Joona I Palaste

Romain said:
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.
 
R

Romain

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 :
 
C

CBFalconer

Romain said:
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.
 
A

Alan Balmer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top