Opened 6 years ago

Closed 6 years ago

#768 closed defect (fixed)

Compilation issue with with --std=gnu++17

Reported by: stac47 Owned by: Olly Betts
Priority: normal Milestone: 1.4.8
Component: Build system Version: 1.4.5
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description

I am trying to compile xapian with gcc (GCC) 8.2.1 with the flag --std=gnu++17. I get the following error resulting from the fact C++17 introduced the type std::byte:

./backends/chert/chert_table.h:848:2: error: reference to ‘byte’ is ambiguous
  byte * split_p;

/remote/tools/Linux/2.6/1A/toolchain/x86_64-2.6.32-v4.0.27/include/c++/8.2.1/bits/cpp_type_traits.h:395:30: note: candidates are: ‘enum class std::byte’
   enum class byte : unsigned char;

./common/internaltypes.h:32:17: note:                 ‘typedef uint8_t byte’
 typedef uint8_t byte;

Of course this error is only en excerpt from a hundred occurrences.

Thanks in advance for your help.

Change History (3)

comment:1 by Olly Betts, 6 years ago

Component: OtherBuild system

This definitely needs addressing, but is there a good reason to be compiling the library itself with --std=gnu++17 at this point?

The external API headers should work fine with --std=gnu++17, and so you should be able to compile the library using GCC 8.2.0 with its default C++ dialect, and then use it in an application you compile with --std=gnu++17.

(And even if/when a future GCC switches to C++17 by default, using --std=gnu++14 or --std=gnu++11 should still work for compiling the library).

comment:2 by Olly Betts, 6 years ago

Milestone: 1.4.8
Status: newassigned

Fixed on git master by c28124139c4a347d5e9743c3c048f49648b35828 - I switched to just use uint8_t (the use of our byte typedef predates C++11).

The patch should be safe to backport to 1.4.x, so marking for 1.4.8.

comment:3 by Olly Betts, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.