Hi Mark,
Using std::hash with enum types (and
PicamParameter is an enum) might be the issue:
https://stackoverflow.com/questions/18837857/cant-use-enum-class-as-unordered-map-key
The Galil driver declares a map like:
std::unordered_map<std::string, Source> map
And std::string was already supported as a hash type in C++11.
Using enum for the hash
was fixed in C++14, so for gcc 4.8.5 can you try this and see if it works?
USR_CXXFLAGS_Linux += -std=c++1y
C++14 is the default for gcc 8.5.0, which might explain why it works on Centos 8.
Cheers,
Matt
From: Tech-talk <tech-talk-bounces at aps.anl.gov>
On Behalf Of Mark Rivers via Tech-talk
Sent: Tuesday, June 13, 2023 1:55 PM
To: Mark Rivers <rivers at cars.uchicago.edu>; tech-talk at aps.anl.gov
Subject: [EXTERNAL] RE: C++ std problem
I should add that ADPICam.cpp compiles fine on Centos 8 Stream (gcc 8.5.0).
I have compiled other files that use std::unordered_map on gcc 4.8.5 without problems, for example the EPICS Galil motor controller.
Thanks,
Mark
I am trying to build areaDetector/ADPICam on Centos 7 (gcc 4.8.5). It uses std::unordered_map which I believe was added in C++11.
If I compile without this line in the Makefile
USR_CXXFLAGS_Linux += -std=c++11
then I get this error, which is expected because it is not using C++11.
/usr/bin/g++ -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_X86_64_ -DUNIX -Dlinux -O3 -g -Wall -mtune=generic -m64 -fPIC -I. -I../O.Common
-I. -I. -I.. -I../../../include/compiler/gcc -I../../../include/os/Linux -I../../../include -I/corvette/home/epics/devel/asyn-4-43/include -I/corvette/home/epics/devel/areaDetector-3-12-1/ADSupport/include/os/Linux -I/corvette/home/epics/devel/areaDetector-3-12-1/ADSupport/include
-I/corvette/home/epics/devel/areaDetector-3-12-1/ADCore/include -I/corvette/usr/local/epics-devel/base-7.0.7/include/compiler/gcc -I/corvette/usr/local/epics-devel/base-7.0.7/include/os/Linux -I/corvette/usr/local/epics-devel/base-7.0.7/include -c ../ADPICam.cpp
In file included from /usr/include/c++/4.8.2/unordered_map:35:0,
from ../ADPICam.h:16,
from ../ADPICam.cpp:19:
/usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This
support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from ../ADPICam.cpp:19:0:
../ADPICam.h:546:33: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
bool imageThreadKeepAlive = true;
^
../ADPICam.h:553:5: error: 'unordered_map' in namespace 'std' does not name a type
std::unordered_map<PicamParameter, int> parameterExistsMap;
If I use the c++11 flag then I get this error:
make[1]: Entering directory `/home/epics/devel/areaDetector-3-12-1/ADPICam/PICamApp/src/O.linux-x86_64'
/usr/bin/g++ -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_X86_64_ -DUNIX -Dlinux -O3 -g -Wall -std=c++11 -mtune=generic -m64 -fPIC -I. -I../O.Common -I. -I. -I.. -I../../../include/compiler/gcc -I../../../include/os/Linux -I../../../include -I/corvette/home/epics/devel/asyn-4-43/include -I/corvette/home/epics/devel/areaDetector-3-12-1/ADSupport/include/os/Linux -I/corvette/home/epics/devel/areaDetector-3-12-1/ADSupport/include -I/corvette/home/epics/devel/areaDetector-3-12-1/ADCore/include -I/corvette/usr/local/epics-devel/base-7.0.7/include/compiler/gcc -I/corvette/usr/local/epics-devel/base-7.0.7/include/os/Linux -I/corvette/usr/local/epics-devel/base-7.0.7/include -c ../ADPICam.cpp
In file included from /usr/include/c++/4.8.2/bits/hashtable.h:35:0,
from /usr/include/c++/4.8.2/unordered_map:47,
from ../ADPICam.h:16,
from ../ADPICam.cpp:19:
/usr/include/c++/4.8.2/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::_Hash_code_base<PicamParameter, std::pair<const PicamParameter, int>, std::__detail::_Select1st, std::hash<PicamParameter>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>':
/usr/include/c++/4.8.2/bits/hashtable_policy.h:1402:10: required from 'struct std::__detail::_Hashtable_base<PicamParameter, std::pair<const PicamParameter, int>, std::__detail::_Select1st, std::equal_to<PicamParameter>, std::hash<PicamParameter>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >'
/usr/include/c++/4.8.2/bits/hashtable.h:174:11: required from 'class std::_Hashtable<PicamParameter, std::pair<const PicamParameter, int>, std::allocator<std::pair<const PicamParameter, int> >, std::__detail::_Select1st, std::equal_to<PicamParameter>, std::hash<PicamParameter>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >'
/usr/include/c++/4.8.2/bits/unordered_map.h:100:18: required from 'class std::unordered_map<PicamParameter, int>'
../ADPICam.h:553:45: required from here
/usr/include/c++/4.8.2/bits/hashtable_policy.h:1070:12: error: invalid use of incomplete type 'struct std::hash<PicamParameter>'
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2,
^
In file included from /usr/include/c++/4.8.2/bits/basic_string.h:3033:0,
from /usr/include/c++/4.8.2/string:52,
from /usr/include/c++/4.8.2/random:41,
from /usr/include/c++/4.8.2/bits/stl_algo.h:65,
from /usr/include/c++/4.8.2/algorithm:62,
from ../ADPICam.cpp:11:
/usr/include/c++/4.8.2/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<PicamParameter>'
struct hash;
^
In file included from /usr/include/c++/4.8.2/bits/hashtable.h:35:0,
from /usr/include/c++/4.8.2/unordered_map:47,
from ../ADPICam.h:16,
from ../ADPICam.cpp:19:
/usr/include/c++/4.8.2/bits/hashtable_policy.h:1070:12: error: invalid use of incomplete type 'struct std::hash<PicamParameter>'
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2,
^
In file included from /usr/include/c++/4.8.2/bits/basic_string.h:3033:0,
from /usr/include/c++/4.8.2/string:52,
from /usr/include/c++/4.8.2/random:41,
from /usr/include/c++/4.8.2/bits/stl_algo.h:65,
from /usr/include/c++/4.8.2/algorithm:62,
from ../ADPICam.cpp:11:
/usr/include/c++/4.8.2/bits/functional_hash.h:58:12: error: declaration of 'struct std::hash<PicamParameter>'
struct hash;
Can anyone explain what that error means, and is it possible to use gcc 4.8.5 to compile this file?
Mark