A
Andreas Griesmayer
Hi,
following piece of code causes a strange behavior when compiled with GCC
(Linux, Gentoo 3.3.5.20050130-r1). read() is called twice although only
called once, the first time before the first statement of main !
I guess there is some call to another read-function my function is wrongly
linkted to, it works fine if read() is renamed or static.
Compilation does not produce any warnings. Can anyone explain this behavior
to me or reproduce it with another compiler/operating system?
thanks,
Andreas
---------------- SNIP ---------------
#include <stdio.h>
int bit_calc(signed char bits)
{ /* do something */
}
int read(){
int value;
printf("please enter a number between -128 and 127: ");
scanf("%d",&value);
return(value);
}
int main(){
printf("start of main()\n");
signed char bits = 0;
int countbits=0;
bits=read();
//...
return 0;
}
-----------------------------------------
following piece of code causes a strange behavior when compiled with GCC
(Linux, Gentoo 3.3.5.20050130-r1). read() is called twice although only
called once, the first time before the first statement of main !
I guess there is some call to another read-function my function is wrongly
linkted to, it works fine if read() is renamed or static.
Compilation does not produce any warnings. Can anyone explain this behavior
to me or reproduce it with another compiler/operating system?
thanks,
Andreas
---------------- SNIP ---------------
#include <stdio.h>
int bit_calc(signed char bits)
{ /* do something */
}
int read(){
int value;
printf("please enter a number between -128 and 127: ");
scanf("%d",&value);
return(value);
}
int main(){
printf("start of main()\n");
signed char bits = 0;
int countbits=0;
bits=read();
//...
return 0;
}
-----------------------------------------