areaDetector / ADPICam

areaDetector driver for Princeton Instruments cameras using the PICam library
https://areadetector.github.io/areaDetector/ADPICam/PICamDoc.html
3 stars 4 forks source link

Add specialization for std::hash for PicamParameter to build on older… #19

Open jwlodek opened 1 year ago

jwlodek commented 1 year ago

… g++ compilers

Did some research after seeing : https://epics.anl.gov/tech-talk/2023/msg00864.php

And found this stack overflow result with a similar compiler error: https://stackoverflow.com/questions/32267070/invalid-use-of-incomplete-type-struct-stdhash-with-unordered-map-with-stdpai

I can confirm that this allows the sources to compile on centos 7 w/ g++ version 4.8.5 when the --std=c++11 flag is also used:

[root@496a12ffa07a ADPICam]# g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 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.

[root@496a12ffa07a ADPICam]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@496a12ffa07a ADPICam]# make -s
../ADPICam.cpp: In static member function 'static PicamError ADPICam::piAcquistionUpdated(PicamHandle, const PicamAvailableData*, const PicamAcquisitionStatus*)':
../ADPICam.cpp:1904:16: warning: variable 'status' set but not used [-Wunused-but-set-variable]
     asynStatus status;
                ^
../ADPICam.cpp: In static member function 'static asynStatus ADPICam::piAddDemoCamera(const char*)':
../ADPICam.cpp:1924:10: warning: variable 'modelFoundInList' set but not used [-Wunused-but-set-variable]
     bool modelFoundInList = false;
          ^
../ADPICam.cpp: In member function 'void ADPICam::piHandleNewImageTask()':
../ADPICam.cpp:4896:16: warning: variable 'error' set but not used [-Wunused-but-set-variable]
     PicamError error;
                ^
/usr/bin/ld: cannot find -lpicam
/usr/bin/ld: cannot find -lpida
/usr/bin/ld: cannot find -lpidi
/usr/bin/ld: cannot find -lpicc
/usr/bin/ld: cannot find -lpiac
collect2: error: ld returned 1 exit status
make[5]: *** [PICamApp] Error 1
make[4]: *** [install.linux-x86_64] Error 2
make[3]: *** [src.install] Error 2
make[2]: *** [PICamApp.install] Error 2
make[1]: *** [PICamIOC.install] Error 2
make: *** [iocs.install] Error 2

This was ran in a container and I did not install the picam software, hence the linker error, but since it got to the linker step the sources were compiled successfully.

ericonr commented 1 year ago

The SO author's concern about this being undefined behavior is a bit worrying :thinking: