Problem występuje podczas kompilacji i uruchomienia programu w wersji Debug.Kod, gdzie wystepuje problem:double dbRadius = sqrt((double)(dwVarX*dwVarX+dwVarY*dwVarY));if (dbRadius >= 20 && dbRadius <= 100){ double dbAngle = acos(dwVarY/dbRadius)*(dwVarX >= 0)?(1):(-1); nMousePosH = (LONG)floor(dbAngle*7/3); nMousePosV = (LONG)floor((90-dbRadius)*3); ...}Zauważyłem, że gdy zostanie zapisana linia inicjalizująca zmienną, a po niej linia porównująca tą zmienną z paroma wartościami, kompilator optymalizuje te linie usuwając zmienną oraz porównując tymczasowo obliczoną wartość. Niestety w moim przypadku nie zostało wykryte ponowne użycie tej zmiennej wewnątrz bloku. W wersji Debug wartość ta zostaje przyrównana do 0.---------------------The problem occurs during compilation and running the application in Debug mode.The code where the problem is:double dbRadius = sqrt((double)(dwVarX*dwVarX+dwVarY*dwVarY));if (dbRadius >= 20 && dbRadius <= 100){ double dbAngle = acos(dwVarY/dbRadius)*(dwVarX >= 0)?(1):(-1); nMousePosH = (LONG)floor(dbAngle*7/3); nMousePosV = (LONG)floor((90-dbRadius)*3); ...}I noticed that, when the line which initialize a variable followed by if statement will be written, the compiler optimizes this lines by removing a variable from memory, and using temporary calculated value. Unfortunately, in this case later use of this variable within the block has not been detected. In Debug mode this variable was evaluated to 0.========== EDIT ==========Problem został rozwiązany, przez przypadek pomyliłem nazwy zmiennych i wychodził zupełnie inny wynik. Podejrzewałem błąd, ponieważ nie mogłem odczytać wartości zmiennej w oknie "watch". Program działa teraz bez zarzutu, przepraszam za problem.The problem was solved. Accidentaly I misspelled variable name and that is why I was different result. I suspected an error, because I could not read the value of the variable in "watch" window. The program works fine now, sorry for the problem.
Visual Studio/Team Foundation Server/.NET Framework Tooling Version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results