0

When trying to compile this with c++ on Ubuntu, I'm getting the error: ‘options’ does not name a type. This is on line 8.

#include "rocksdb/db.h"
#include <cassert>

using namespace rocksdb;

DB* db;
Options options;
options.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(options, "/tmp/testdb", &db);
assert(status.ok());

I'm very new to C++, and can't make sense of why the type hasn't registered with the "Options options" variable declaration. I've looked at the definition of the Options struct, and create_if_missing is one of the properties. Any ideas?

Jonathan
  • 67
  • 1
  • 3
  • 2
    is this your code? Because you can't execute statements when you are not in a function `options.create_if_missing = true` needs to happen in a function – Raildex Nov 03 '21 at 07:48
  • 1
    The code seems to come from http://rocksdb.org/docs/getting-started.html – Passerby Nov 03 '21 at 07:48
  • 1
    Just put everything under `using namespace rocksdb;` in `int main() {` ... `}` – Ted Lyngmo Nov 03 '21 at 07:50
  • 1
    The example you found is broken. Get a [good book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and start at the beginning. – molbdnilo Nov 03 '21 at 09:11

0 Answers0