[odb-users] ODB 2.5.0 compiler error
Paul Stath
PStath at jmawireless.com
Tue Apr 1 17:59:24 EDT 2025
Hi Boris,
I'm porting one of our ODB projects from Redhat 8 to Redhat 9.
As part of that effort, I'm trying to upgrade to the ODB 2.5.0 release.
I have compiled the build2 toolchain and also:
* odb
* libodb
* libodb-sqlite
* libodb-boost
The compiler is GCC v 11.3.1:
$ g++ --version
g++ (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ rpm -qa | grep gcc
libgcc-11.3.1-4.3.el9.x86_64
gcc-11.3.1-4.3.el9.x86_64
gcc-plugin-annobin-11.3.1-4.3.el9.x86_64
gcc-c++-11.3.1-4.3.el9.x86_64
gcc-plugin-devel-11.3.1-4.3.el9.x86_64
The bpkg tests run successfully:
$ bpkg test odb
ld odb-2.5.0/odb/plugin{odb}
ld odb-2.5.0/odb/exe{odb}
test odb-2.5.0/tests/testscript{testscript}
tested odb/2.5.0
$ bpkg test --all --recursive
ld libodb-boost-2.5.0/odb/boost/libs{odb-boost}
ld libodb-sqlite-2.5.0/odb/sqlite/libs{odb-sqlite}
ld libodb-boost-2.5.0/tests/basics/exe{driver}
ld libodb-sqlite-2.5.0/tests/basics/exe{driver}
test libodb-2.5.0/tests/basics/exe{driver}
test libodb-boost-2.5.0/tests/basics/exe{driver}
test libodb-sqlite-2.5.0/tests/basics/exe{driver}
tested libodb/2.5.0
tested libodb-sqlite/2.5.0
tested libodb-boost/2.5.0
I am using the PRAGMA_DB() inline macros in my hxx files.
PRAGMA_DB(object readonly)
class Passwd : public std::enable_shared_from_this<Passwd> {
public:
static constexpr unsigned int CRYPT_ITERATIONS = 10000;
using pointer = std::shared_ptr<Passwd>;
using key_t = unsigned long;
~Passwd();
static pointer create(const std::string& plainText, bool strict = true);
bool authenticate(const std::string& plainText) const;
static void validatePasswd(const std::string& passwd, bool strict = true);
key_t key() const { return key_; }
private:
friend std::ostream& operator<<(std::ostream&, const Passwd&);
friend class odb::access;
friend class User;
Passwd(); // Requited by ODB
PRAGMA_DB(id auto)
key_t key_;
PRAGMA_DB(not_null)
std::weak_ptr<User> user_;
PRAGMA_DB(type("TEXT"))
crypt_buff salt_;
unsigned int iterations_;
PRAGMA_DB(type("TEXT"))
crypt_buff digest_; // password digest
};
When I attempt to use the odb compile command, I get errors like the following:
Auth.hpp:60:5: error: db pragma 'id' is not associated with a declaration
Auth.hpp:63:5: error: db pragma 'not_null' is not associated with a declaration
Auth.hpp:66:5: error: db pragma 'type' is not associated with a declaration
Auth.hpp:66:5: error: db pragma 'type' is not associated with a declaration
Auth.hpp:71:5: error: db pragma 'type' is not associated with a declaration
Auth.hpp:71:5: error: db pragma 'type' is not associated with a declaration
It doesn't complain about the "PRAGMA_DB(object readonly) line located right before the class.
If comment out the positioned pragmas and add named parameters, the ODB code is generated properly.
It looks like the positioned pragmas are not being matched up with the data member variables.
Hopefully I'm just missing something simple?
If you need more information, please ask.
Thanks,
--- Paul
More information about the odb-users
mailing list