简体   繁体   中英

C++: STXXL and VS runtime error in simple code

I have the following code which is a pretty simple test, but the VS refuses to run it:

stxxl::syscall_file OutputFile("Data/test.bin", stxxl::file::RDWR | stxxl::file::CREAT | stxxl::file::DIRECT);
typedef stxxl::VECTOR_GENERATOR<struct Rectangle, 8, 2, 524288>::result vector_type;
vector_type rects(&OutputFile);

the program produces a runtime error in a memory location in the 3rd line . What am I doing wrong? I'm compiling the program for 64-bit platforms. In the Debug mode if I press continue the program resumes and executes without problem.

Consider the following example:

#include <stxxl/io>
#include <stxxl/vector>  
#include <iostream>

struct Rectangle { 
  int x; 
  Rectangle() = default;
};  

int main() {
  stxxl::syscall_file OutputFile("/tmp/test.bin", stxxl::file::RDWR |     
                      stxxl::file::CREAT | stxxl::file::DIRECT);
  typedef stxxl::VECTOR_GENERATOR<Rectangle, 8, 2, 524288>::result  vector_type;
  vector_type rects(&OutputFile);

  Rectangle my_rectangle;

  for (std::size_t i = 0; i < 1024 * 1024 * 1024; ++i)       
    rects.push_back(my_rectangle);

  return 0;
}

An error can easily be provoked when there is not enough space left on the device. Can you post your runtime error?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM