Difference between WIN32 and other c string [duplicate]
Possible Duplicate:
Difference between WIN32 and other c string
I got this code inside a small program to read a file
#ifdef WIN32
unsigned char *buffer = (unsigned char *)alloca((unsigned int)ui.length);
#else
unsigned char buffer[ui.length];
#endif
Can anybody tell me , why pointer used for win32 platform and character array for other platfo开发者_Go百科rm?
The code intended to declare an array of length not known at compile time. It was likely written with the assumption that C++ compilers for Windows targets don't support declaring such arrays (for example, Visual C++ doesn't support that). So when compilation is done for Windows targets alloca()
function is used to achieve the same effect.
I guess that the compiler used for WIN32 compilation does not support C99 variable length array declarations.
精彩评论