开发者

Difference between WIN32 and other c string [duplicate]

This question already has answers here: Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜