I wrote a program to save all the detailed file descriptors.
So, I used the sysconf function to resolve the open max file descriptor.
if the array declaration is not in the global value, it does not indicate an error. Works fine.
This is my program
#define MAX_CLIENT sysconf(_SC_OPEN_MAX) int arr[MAX_CLIENT]; main () { printf("%ld \n",MAX_CLIENT); }
when i do compilation with error message
error: variably modified 'arr' at file scope
Then I checked with the cc -E option. After the preprocessor works, the programs look as follows:
int arr[sysconf(_SC_OPEN_MAX)]; main () { printf("%ld \n",sysconf(_SC_OPEN_MAX)); }
this is my problem how to declare an array globally.
source share