pthreads を使用して n-queen パズルを計算するための次のコードがあります。しかし、そのコードをコンパイルしようとすると、次のエラー メッセージが表示されます。
wikithread.c:7:5: エラー: ファイル スコープで可変的に変更された 'hist'
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
int NTHREADS, SIZE; 
int hist[SIZE];
int count = 0;
int solve(int col, int tid)
{
    int start = tid * SIZE/NTHREADS;
    int end = (tid+1) * (SIZE/NTHREADS) - 1;
    int i, j;
    if (col == SIZE) 
    {
        count++;
    }
    #define attack(i, j) (hist[j] == i || abs(hist[j] - i) == col - j)
    for (i = start; i <= end; i++) {
        for (j = 0; j < col && !attack(i, j); j++);
        if (j < col) continue;
        hist[col] = i;
        solve(col + 1, tid);
    }
    return count;
}
void *worker(void *arg)
{
    int tid = (int)arg;
    solve(0, tid);
}
int main(int argc, char* argv[])
{
    pthread_t* threads;
    int rc, i;
    // checking whether user has provided the needed arguments
    if(argc != 3)
    {
        printf("Usage: %s <number_of_queens> <number_of_threads>\n", argv[0]);
        exit(1);
    }
    // passing the provided arguments to the SIZE and NTHREADS 
    // variable, initializing matrices, and allocating space 
    // for the threads
    SIZE = atoi(argv[1]);
    NTHREADS = atoi(argv[2]);
    threads = (pthread_t*)malloc(NTHREADS * sizeof(pthread_t));
    // declaring the needed variables for calculating the running time
    struct timespec begin, end;
    double time_spent;
    // starting the run time
    clock_gettime(CLOCK_MONOTONIC, &begin);
    for(i = 0; i < NTHREADS; i++) {
        rc = pthread_create(&threads[i], NULL, worker, (void *)i);
        assert(rc == 0); // checking whether thread creating was successfull
    }
    for(i = 0; i < NTHREADS; i++) {
        rc = pthread_join(threads[i], NULL);
        assert(rc == 0); // checking whether thread join was successfull
    }
    // ending the run time
    clock_gettime(CLOCK_MONOTONIC, &end);
    // calculating time spent during the calculation and printing it
    time_spent = end.tv_sec - begin.tv_sec;
    time_spent += (end.tv_nsec - begin.tv_nsec) / 1000000000.0;
    printf("Elapsed time: %.2lf seconds.\n", time_spent);
    printf("\nNumber of solutions: %d\n", count);
    return 0;
}
上部を変更し、配列にメモリを動的に割り当てると、次のエラーが発生します。
int NTHREADS, SIZE; 
int *hist;
hist = (int*)malloc(SIZE * sizeof(int));
次に、次のエラーが表示されます。
wikithread.c:8:1: 警告: データ定義にタイプまたはストレージ クラスがありません [デフォルトで有効] wikithread.c:8:1: エラー: 'hist' wikithread.c:7:6: ノート: 以前の「hist」の宣言はここにありましたvector wikithread.c:23:27: エラー: 添え字付きの値は配列でもポインターでもベクトルでもありません wikithread.c:26:7: エラー: 添え字付きの値は配列でもポインターでもベクトルでもありません
誰でも、問題を解決するのを手伝ってくれますか?