The difference between WIN32 and another line c

Possible duplicate:
The difference between WIN32 and another line c

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 someone tell me why the pointer is used for the win32 platform and the character array for another platform?

+4
source share
2 answers

Code intended to declare an array of length unknown at compile time. This was probably written with the assumption that C ++ compilers for Windows purposes do not support the declaration of such arrays (for example, Visual C ++ does not support this). Therefore, when compiling is done for Windows purposes, the alloca() function is used to achieve the same effect.

+2
source

I assume that the compiler used to compile WIN32 does not support C99 variable length array declarations.

+1
source

Source: https://habr.com/ru/post/1345832/


All Articles