visual c++ - When will _ATL_ALLOW_UNSIGNED_CHAR work? -


i'm migrating visual c++ project uses atl/mfc vs2010 vs2013. project compiles /j ("assume char unsigned"), , there code may or may not rely on fact remove compiler flag.

under vs2013, /j causes compiler error in atldef.h: atl doesn't support compilation /j or _char_unsigned flag enabled. can suppressed defining _atl_allow_unsigned_char. microsoft mention in msdn documentation /j, along vague statement: "if use compiler option atl/mfc, error might generated. although disable error defining _atl_allow_char_unsigned, workaround not supported , may not work."

does know under circumstances safe or unsafe use _atl_allow_char_unsigned?

microsoft struggles keep ancient codebases, atl, compatible changes in compiler. principal trouble-maker here atlgethexvalue() function. had design mistake:

the numeric value of input character interpreted hexadecimal digit. example, input of '0' returns value of 0 , input of 'a' returns value of 10. if input character not hexadecimal digit, this function returns -1.

-1 rub, 9 years ago broke /j in effect. , won't return -1 today, returns char_max ((char)255) if compile /j. required since comparing unsigned char -1 false , entire if() statement omitted. broke atl itself, break code in nasty way if use function, given code on error path unlikely tested.

shooting off hip, there 3 basic ways have solved problem. have changed return value type int, risking breaking everybody. or have noted special behavior in msdn article, making everybody's eyes roll. or have invoked "time move on" option. picked, time msvc++ being laughing stock of programming world then.

that's need fear atl, low odds using function , easy find back. otherwise excellent hint kind of trouble might own code.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -