预处理程序指令增加堆栈大小不起作用

时间:2018-03-26 01:44:08

标签: c++ stack preprocessor-directive

#include <iostream> 
#include <ctime> 
#include <cstdlib>
using namespace std;

void showArray(int data[], int n);
int partition(int data[], int low, int high);
void quicksort(int data[], int low, int high);
void sort(int data[], int n);

int comparisonCount;
int sortCount;

#pragma comment(linker, "/STACK: 8000000")


int main()
{
srand((unsigned)time(0));
int random_integer;
int lowest = 1, highest = 1000;
int range = (highest - lowest) + 1;
int arrayList[1000];


for (int i = 0; i < highest; i++) {
    random_integer = lowest + int(range*rand() / (RAND_MAX + 1.0));
    arrayList[i] = random_integer;
}


sort(arrayList, highest);
showArray(arrayList, highest);


}

每当我尝试运行此操作时,我都会收到错误... invalid directive '8000000' found; does not start with '/'

此代码中看不见的部分将涉及大量递归,因此需要增加堆栈大小。我不知道导演为什么不工作。

1 个答案:

答案 0 :(得分:2)

链接器选项中不应包含任何空格。

#pragma comment(linker, "/STACK:8000000")
//                              ^ no space here