[odb-users] ODB requires x++11

Justin Armstrong justinarmstrong at vectormagnetics.com
Thu Jul 20 13:16:15 EDT 2023


Hi Paul,

Thanks for getting back to me, and for your help.

I have reduced the issue to a simple example that excludes all the project specifics.


When I try to compile the below code with : clang main.cpp -std=c++17

main.cpp


#include <stdio.h>
#include <odb/transaction.hxx>

int main(int argc, const char* argv[]) {
    printf("Test ODB with c++17\n");
    return 0;
}

I get :

clang main.cpp -std=c++17
In file included from main.cpp:4:
In file included from /usr/local/include/odb/transaction.hxx:263:
In file included from /usr/local/include/odb/transaction.ixx:5:
In file included from /usr/local/include/odb/connection.hxx:17:
In file included from /usr/local/include/odb/traits.hxx:11:
/usr/local/include/odb/pointer-traits.hxx:165:30: error: no member named 'auto_ptr' in namespace 'std'
  class pointer_traits< std::auto_ptr<T> >
                        ~~~~~^
/usr/local/include/odb/pointer-traits.hxx:165:39: error: 'T' does not refer to a value
  class pointer_traits< std::auto_ptr<T> >
                                      ^
/usr/local/include/odb/pointer-traits.hxx:164:22: note: declared here
  template <typename T>
                     ^
/usr/local/include/odb/pointer-traits.hxx:165:42: error: expected unqualified-id
  class pointer_traits< std::auto_ptr<T> >

And other similar errors.

I am using clang :

clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

The common runtime that I am including is from :

https://www.codesynthesis.com/products/odb/download.xhtml

Common Runtime Library
libodb-2.4.0


Let me know if you have more questions, thoughts on workarounds or if I’m missing something basic about this.



Best,

Justin



On Jul 19, 2023, at 3:03 PM, Paul Stath <PStath at jmawireless.com<mailto:PStath at jmawireless.com>> wrote:

Hi Boris and Justin,

Line 165 in the odb/pointer-traits.hxx file is inside a template specialization for:
   template <typename T>
   class pointer_traits<std::auto_ptr<T> >

The full output from the compile command would be very helpful, since it would show what compilation units are including the "pointer-traits.hxx" file.

Even without that output, I would guess that a 'std::auto_ptr' is being used somewhen and when compiled with a C++17 compiler, the error is generated when the template is being expanded.

The 'std::auto_ptr' could easily be in the generated ODB code if the "--default-pointer: argument with a value of "std::auto_ptr" is specified in the ODB compiler command line.

I would suggest searching for "auto_ptr" in the source files of the project.  (Including the generated ODB files.)
In order to compile with C++17 or later, these would need to be converted to "std::unique_ptr".

--- Paul


-----Original Message-----
From: Boris Kolpackov <boris at codesynthesis.com<mailto:boris at codesynthesis.com>>
Sent: Wednesday, July 19, 2023 11:14 AM
To: Justin Armstrong <justinarmstrong at vectormagnetics.com<mailto:justinarmstrong at vectormagnetics.com>>
Cc: odb-users at codesynthesis.com<mailto:odb-users at codesynthesis.com>
Subject: Re: [odb-users] ODB requires x++11

Justin Armstrong <justinarmstrong at vectormagnetics.com<mailto:justinarmstrong at vectormagnetics.com>> writes:

I meant auto_ptr. In odb/pointer-traits.hxx line 165 I get an error
when compiling with -std=c++17. So the issue I’m having is in the
supporting code not the odb generated code.

pointer-traits.hxx

 // Specialization for std::auto_ptr.
 //
 template <typename T>
 class pointer_traits< std::auto_ptr<T> > // line 165

Hm, interesting, maybe we should exclude this specialization for later C++
versions.

The strange thing is that we don't have any issues with it even though we are
compiling with up to C++23 using pretty much every compiler (GCC, Clang,
MSVC). Can you share the compiler/version as well as the exact command line
that you are using to compile your code? There must be something like -
pedantic that causes this.


[EXTERNAL EMAIL] DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.



More information about the odb-users mailing list