简体   繁体   中英

Why UuidFromString function requests non-const pointer to unsigned char?

I have no idea why UuidFromString function requered non-const pointer to unsigned char. Why not const char* instead?

My thoughts that there is no need to data modification pointed by the first argument.

UuidFromString was designed for COM/DCOM.

The unsigned char is to prevent the need to check for negative char values (the default char is signed , meaning the values ranged [-128, 127] - since this string is supposed to be ANSI characters, it is a cheap way to avoid having a < 0 conditional check).

Its sister function ( UuidToString ) does take a const input parameter. I do not see a reason in the documentation as to why UuidFromString does not as well, but it is likely an oversight that was never addressed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM