i under impression accessing union member other last 1 set ub, can't seem find solid reference (other answers claiming it's ub without support standard). so, undefined behavior? the confusion c explicitly permits type-punning through union, whereas c++ ( c++11 ) has no such permission. c11 6.5.2.3 structure , union members 95) if member used read contents of union object not same member last used store value in object, appropriate part of object representation of value reinterpreted object representation in new type described in 6.2.6 (a process called ââtype punningââ). might trap representation. the situation c++: c++11 9.5 unions [class.union] in union, @ 1 of non-static data members can active @ time, is, value of @ 1 of non-static data members can stored in union @ time. c++ later has language permitting use of unions containing struct s common initial sequences; doesn't permit type-punning. to determine whether union type-punning is allowe...
i new java. writing wrapper-library in java make functions available in basic-like language. i got stock @ point when noted code not executed in java-library although compiler did not complain (using eclipse). resolved replacing code follows: public void videoquality(int vquality) //did not work into public boolean videoquality(int vquality) //works here complete code-snippets: public void videoquality(int vquality) //did not work {if (vquality==16) { vidquality=16; } else if (vquality==-16) { vidquality=-16; } else if (vquality==0) { vidquality=0; } else vidquality=-16; vitamioext.setvideoquality(vidquality); } public boolean videoquality(int vquality) //works {if (vquality==16) { vidquality=16; } else if (vquality==-16) { vidquality=-16; } else if (vquality==0) { vidquality=0; } else vidquality=-16; vitamioext.setvideoquality(vidquality); return true; } i think void corresponds sub in visual basic while boolean corresponds function. i found odd following code worked using...
Comments
Post a Comment