1

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.

TheShadow
  • 69
  • 1
  • 9
  • This works for me on Linux without any runtime errors. Is `Rectangle` a POD? Does this [example](http://stxxl.sourceforge.net/tags/master/examples_2algo_2copy_and_sort_file_8cpp-example.html#_a6) work on your platform? – Daniel F Jan 15 '16 at 00:46
  • Yes it has 3 unsigned ints and 2 float arrays with the size declared. I've tested other examples and the seem work fine. I tried to remove the arrays but it made no difference. – TheShadow Jan 15 '16 at 01:32
  • Thanks for the answer! The compiler gives me errors at default and the first struct keyword. What is the purpose of this code? – TheShadow Jan 15 '16 at 23:39

1 Answers1

0

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?

Daniel F
  • 283
  • 3
  • 11