TBBW Posted April 12, 2012 Posted April 12, 2012 Hi all,maybe the dummest quest of the day....butmsvs 2010 does not compile the '/', '*' and '%' operators....(well it does compile, but the answers are not there.)I had the same issue using excell changed '/' to '-' problem solved.regards,ger
ghandi Posted April 12, 2012 Posted April 12, 2012 Compiler settings? If you have optimization on and are not using the results of the operations for anything, the compiler will leave the code out of the final executable because it determines it to be 'redundant'.HR,Ghandi
TBBW Posted April 12, 2012 Author Posted April 12, 2012 Hi,No I use the answers.the statement;var1 = var2 * var3;var1 = var1 + var1;should work, but it does not......regards,ger
Killboy Posted April 12, 2012 Posted April 12, 2012 What do you mean by "should work"? More importantly, how do you know it "does not"?A few options:- as ghandi said, optimization may remove unused code; sometimes (especially in older versions of VS) they introduce bugs caused by undefined behaviour. temporarily turn them off and check again.- there might be a bug in your code (some of the initial parameters might be flawed to begin with). you could use the code analyzer that comes with VS, sometimes it helps.- your way of checking the results may skew things (are you debugging? use a debug build, and the watch in the VS debugger)
atom0s Posted April 13, 2012 Posted April 13, 2012 Care to post an actual code example of what you are trying to compile? Perhaps you are overlooking somethng minor that isn't an actual bug.
ghandi Posted April 13, 2012 Posted April 13, 2012 Aside from agreeing wholeheartedly with atom0s and Killboy, there is also the issue of your original post stating that the operators '/' and '%' weren't functioning but in your 'snippet' you don't use either operator, instead using '+' and '*'.As atom0s said, you should post the code in question and that way people can get a proper idea of what is happening. Your snippet still does nothing with the 'var1' result, which the compiler would see as redundant, thus removing it if optimizations are set to do so.HR,Ghandi
TBBW Posted April 13, 2012 Author Posted April 13, 2012 Hi all,PROBLEM SOLVED !!As Ghandi stated the outcome of the statement was not used....I 'accidently' marked the line in which I used the outcome using // comment marks.So the compiler removed my statement.Thanks all,ger
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now