Re: ide project vs. command_line
This is a multi-part message in MIME format.
------=_NextPart_000_002A_01C76C89.C0DD5AC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
This code exibits undefined behavior. This means even the compiler =
cannot guarantee what you'll get.
Hint: look up "side effect" and "sequence point" in your favorite C =
tutorial.
"Robert Wong" <robertwong@hotmail.com> wrote in message =
news:ePZCnvLbHHA.4656@TK2MSFTNGP06.phx.gbl...
Hi there,
I'm trying to switch to VS 2005, there are some problems with porting =
existing code. I found something interesting in the project environment =
with this code:
#include <stdio.h>
#include <stdlib.h>
void abcd(char *dummy,int si,int value)
{
int x;
x = si;
// VC++ 6.0 shows, si = 0, value = 5
// Visual Studio 2005 shows , si = 1 (in project)
// command line "cl <file> shows si=0
// in ide project, si=1, value=0
printf("si = %i value = %i",si,value);
}
void main(void)
{
int si;
si = 0;
short int iblock[2] = {0,1};
abcd("do something",si,iblock[si++]);
}
-------------
I don't think it's a optimization issue, since the IDE debug is turn =
off (disable) optimization. In Visual C++, I gotten the value of the =
index is (si=0) inside the body of the subroutine. In Visual Studio =
2005, the value (si=1) inside the body.
Does anyone know which compiler feature this is so I can turn it off?
Thanks,
Robert
------=_NextPart_000_002A_01C76C89.C0DD5AC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>This code exibits undefined behavior. This means =
even the
compiler cannot guarantee what you'll get.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Hint: look up "side effect" and "sequence point" in =
your
favorite C tutorial.</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Robert Wong" <<A
href="mailto:robertwong@hotmail.com">robertwong@hotmail.com</A>> =
wrote in
message <A
=
href="news:ePZCnvLbHHA.4656@TK2MSFTNGP06.phx.gbl">news:ePZCnvLbHHA.4656=
@TK2MSFTNGP06.phx.gbl</A>...</DIV>
<DIV><FONT face=Arial size=2>Hi there,</FONT></DIV>
<DIV><FONT face=Arial size=2> I'm trying to switch to VS =
2005, there are
some problems with porting existing code. I found something =
interesting
in the project environment with this code:</FONT></DIV>
<DIV><FONT face=Arial size=2><FONT =
size=2></FONT></FONT> </DIV>
<DIV><FONT face=Arial size=2><FONT size=2>#include =
<stdio.h><BR>#include
<stdlib.h></DIV>
<DIV>
<P>void abcd(char *dummy,int si,int =
value)<BR>{<BR>
int x;<BR> x = si;<BR> // VC++ 6.0 =
shows,
si = 0, value = 5<BR> // Visual Studio 2005 shows , si = 1 =
(in
project)<BR> // command line "cl <file> shows =
si=0<BR> // in
ide project, si=1, value=0<BR> printf("si =
= %i value =
%i",si,value);<BR>}</P>
<P>void main(void)<BR>{<BR> int
si;<BR> si = 0;<BR> =
short int
iblock[2] = {0,1};<BR> abcd("do
something",si,iblock[si++]);<BR>}<BR>-------------</P>
<P>I don't think it's a optimization issue, since the IDE debug is =
turn off
(disable) optimization. In Visual C++, I gotten the value of the =
index
is (si=0) inside the body of the subroutine. In Visual Studio =
2005, the
value (si=1) inside the body.</P>
<P>Does anyone know which compiler feature this is so I can turn it =
off?</P>
=
<P>Thanks,<BR>Robert</P></FONT></FONT></DIV></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_002A_01C76C89.C0DD5AC0--