epics-modules / sscan

APS BCDA synApps module: sscan
https://epics.anl.gov/bcda/synApps/sscan/sscan.html
Other
2 stars 14 forks source link

READONLY definitions EPICS 7 #20

Closed hjunkes closed 3 years ago

hjunkes commented 3 years ago

Hi, had to change READONLY to const to get it building with EPICS 7

diff --git a/sscanApp/src/saveData.c b/sscanApp/src/saveData.c index 12a6845..66526b7 100644 --- a/sscanApp/src/saveData.c +++ b/sscanApp/src/saveData.c @@ -1844,7 +1844,7 @@ LOCAL void extraValCallback(struct event_handler_args eha) PV_NODE * pnode = eha.usr; long type = eha.type; long count = eha.count;

diff --git a/sscanApp/src/saveData_writeXDR.c b/sscanApp/src/saveData_writeXDR.c index 24ba3df..8fff761 100644 --- a/sscanApp/src/saveData_writeXDR.c +++ b/sscanApp/src/saveData_writeXDR.c @@ -1838,7 +1838,7 @@ LOCAL void extraValCallback(struct event_handler_args eha) PV_NODE * pnode = eha.usr; long type = eha.type; long count = eha.count;

ralphlange commented 3 years ago

Where is READONLY supposed to be defined?

hjunkes commented 3 years ago

in include/shareLib.h

ralphlange commented 3 years ago

Then the appropriate fix should be to #include <shareLib.h>, right?

hjunkes commented 3 years ago

I had in memory that with EPICS 7 changes were made to shareLib & Co. and thought that would be outdated. If that is not the case, then the include insert is the way to go. Thanks.

(Just tested it too)

MarkRivers commented 3 years ago

@hjunkes what version of sscan are you using, and on what platform?

I build sscan fine on base 7.0.5 on Linux, Windows, and vxWorks.

Recent versions and master branch of sscan do not build saveData.c. This is from sscanApp/src/Makefile:

# save scan data stuff
sscan_SRCS += saveData_writeXDR.c, writeXDR.c

# The old saveData code, in case it's still needed on some platform
#sscan_SRCS += xdr_lib.c
#sscan_SRCS += saveData.c
#sscan_SRCS_vxWorks += xdr_stdio.c
#sscan_SYS_LIBS_cygwin32 += $(CYGWIN_RPC_LIB)
MarkRivers commented 3 years ago

Ping?

hjunkes commented 3 years ago

I assumed that Ralph will fix it ;-) attached a possible patch:

diff --git a/sscanApp/src/saveData.c b/sscanApp/src/saveData.c index 12a6845..a0af470 100644 --- a/sscanApp/src/saveData.c +++ b/sscanApp/src/saveData.c @@ -192,6 +192,7 @@ extern STATUS nfsUnmount(char *localName);

include

include

include

+#include / not in 3.15.0.1 #include /

include

include

diff --git a/sscanApp/src/saveData_writeXDR.c b/sscanApp/src/saveData_writeXDR.c index 24ba3df..f5c83fd 100644 --- a/sscanApp/src/saveData_writeXDR.c +++ b/sscanApp/src/saveData_writeXDR.c @@ -201,6 +201,7 @@

include

include

include

+#include / not in 3.15.0.1 #include /

include

include

ralphlange commented 3 years ago

I assumed that Ralph will fix it ;-)

Full disclosure: I don't know what sscan does, have never used it, and don't expect to.

MarkRivers commented 3 years ago

@hjunkes I am confused. I said above that one file that is causing you problems, saveData.c is no longer used by sscan, it is commented out in the Makefile. You did not answer my question above about what version of sscan you are using, and on what platform? Can you explain why you are having problems with saveData.c?

Your patch adds shareLib.h to another file, saveData_writeXDR.c. That file does use READONLY. It does not include shareLib.h, but it does include epicsExport.h, which includes shareLib.h. It does this after the use of READONLY. But it compiles fine for me on base 7.0.5 on Windows, Linux, and vxWorks. Could that be a problem with some compilers and not others?

/usr/bin/gcc  -D_GNU_SOURCE -D_DEFAULT_SOURCE         -DUSE_TYPED_RSET   -D_X86_64_  -DUNIX  -Dlinux      
-O3 -g   -Wall -Werror-implicit-function-declaration      -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/seq-2-2-5/include 
-I/corvette/usr/local/epics-devel/base-7.0.5/include/compiler/gcc 
-I/corvette/usr/local/epics-devel/base-7.0.5/include/os/Linux 
-I/corvette/usr/local/epics-devel/base-7.0.5/include        -c ../saveData_writeXDR.c
../saveData_writeXDR.c: In function 'saveExtraPV':
../saveData_writeXDR.c:2251:11: warning: variable 'channel' set but not used [-Wunused-but-set-variable]
  chid     channel;
           ^
ralphlange commented 3 years ago

Your patch adds shareLib.h to another file, saveData_writeXDR.c. That file does use READONLY. It does not include shareLib.h, but it does include epicsExport.h, which includes shareLib.h. It does this after the use of READONLY. But it compiles fine for me on base 7.0.5 on Windows, Linux, and vxWorks. Could that be a problem with some compilers and not others?

Sounds strange, but I don't think compilers differ that much in the way they handle include files.

Somehow that source file was involuntarily relying on another EPICS header including shareLib.h before it uses READONLY. That's IMHO just wrong - source files should include the appropriate headers before using their symbols.

MarkRivers commented 3 years ago

Somehow that source file was involuntarily relying on another EPICS header including shareLib.h before it uses READONLY. That's IMHO just wrong - source files should include the appropriate headers before using their symbols.

As I said the current version in sscan builds fine for me on base 7.0.5 on Linux, Windows, and vxWorks. I'd like to see the build message from @hjunkes .

hjunkes commented 3 years ago

I am using sscan from : origin https://github.com/epics-modules/sscan (fetch) origin https://github.com/epics-modules/sscan (push)

commit 04856b2c9c71c4c33a3007db08df8b3ad7e3adbb (HEAD -> master, tag: R2-11-4, origin/master, origin/HEAD) Author: Keenan Lang klang@aps.anl.gov Date: Mon Oct 5 00:51:30 2020 -0500

R2-11-4 Release Notes

git status On branch master Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Makefile shows: ...

save scan data stuff

sscan_SRCS += saveData_writeXDR.c, writeXDR.c

The old saveData code, in case it's still needed on some platform

sscan_SRCS += xdr_lib.c

sscan_SRCS += saveData.c

sscan_SRCS_vxWorks += xdr_stdio.c

sscan_SYS_LIBS_cygwin32 += $(CYGWIN_RPC_LIB)

ok, I guess I "overreacted" to saveData.c :-) and patched that too since it uses the same construct.

Build-message (saveData_writeXDR.c) make -C ./src install make[1]: Entering directory '/home/junkes/LINUX/EPICS/epics-support/sscan/sscanApp/src' make -C O.linux-x86_64 -f ../Makefile TOP=../../.. \ T_A=linux-x86_64 install make[2]: Entering directory '/home/junkes/LINUX/EPICS/epics-support/sscan/sscanApp/src/O.linux-x86_64' /usr/bin/gcc -D_GNU_SOURCE -D_DEFAULT_SOURCE -DUSE_TYPED_RSET -D_X8664 -DUNIX -Dlinux -O3 -g -Wall -Werror-implicit-function-declaration -mtune=generic -m64 -fPIC -I. -I../O.Common -I. -I. -I.. -I../../../include/compiler/gcc -I../../../include/os/Linux -I../../../include -I/home/junkes/LINUX/EPICS/epics-base/include/compiler/gcc -I/home/junkes/LINUX/EPICS/epics-base/include/os/Linux -I/home/junkes/LINUX/EPICS/epics-base/include -I/home/junkes/LINUX/EPICS/epics-support/calc/include -I/home/junkes/LINUX/EPICS/epics-support/sscan/include -I/home/junkes/LINUX/EPICS/epics-support/asyn/include -I/home/junkes/LINUX/EPICS/epics-support/StreamDevice/include -c ../saveData_writeXDR.c ../saveData_writeXDR.c: In function ‘extraValCallback’: ../saveData_writeXDR.c:1841:2: error: unknown type name ‘READONLY’ 1841 | READONLY DBR_VAL pval = eha.dbr; | ^~~~ ../saveData_writeXDR.c:1841:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token 1841 | READONLY DBR_VAL pval = eha.dbr; | ^ ../saveData_writeXDR.c:1850:23: error: ‘pval’ undeclared (first use in this function) 1850 | size= strlen((char)pval); | ^~~~ ../saveData_writeXDR.c:1850:23: note: each undeclared identifier is reported only once for each function it appears in ../saveData_writeXDR.c: In function ‘extraDescCallback’: ../saveData_writeXDR.c:1888:2: error: unknown type name ‘READONLY’ 1888 | READONLY DBR_VAL pval = eha.dbr; | ^~~~ ../saveData_writeXDR.c:1888:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘’ token 1888 | READONLY DBR_VAL pval = eha.dbr; | ^ ../saveData_writeXDR.c:1892:31: error: ‘pval’ undeclared (first use in this function) 1892 | strncpy(pnode->desc, (char )pval, MAX_STRING_SIZE); | ^~~~ make[2]: [/home/junkes/LINUX/EPICS/epics-base/configure/RULES_BUILD:259: saveData_writeXDR.o] Error 1 make[2]: Leaving directory '/home/junkes/LINUX/EPICS/epics-support/sscan/sscanApp/src/O.linux-x86_64' make[1]: [/home/junkes/LINUX/EPICS/epics-base/configure/RULES_ARCHS:58: install.linux-x86_64] Error 2 make[1]: Leaving directory '/home/junkes/LINUX/EPICS/epics-support/sscan/sscanApp/src' make: *** [/home/junkes/LINUX/EPICS/epics-base/configure/RULES_DIRS:85: src.install] Error 2

MarkRivers commented 3 years ago

I'd like to understand why this builds for me and not for you. What versions of the following are you using:

It builds fine for me on base 7.0.5 with the following:

hjunkes commented 3 years ago

epics-base: commit b00130493fe695fad623e509bda9d507fccec019 (HEAD -> 7.0, origin/HEAD, origin/7.0) Author: Michael Davidsaver mdavidsaver@gmail.com Date: Wed Apr 21 16:03:36 2021 -0700

Ubuntu 20.04.2 LTS

gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

MarkRivers commented 3 years ago

Interesting. Is the difference due to the compiler, or due to a change in base?

MarkRivers commented 3 years ago

I just checked out the 7.0 branch. It fails on Centos 7, gcc 4.8.5. So the difference is a change in the include files in base.

MarkRivers commented 3 years ago

Fixed via 420274ca2e4331e92119bd0524d0bcd7ffdd9f93.

MarkRivers commented 3 years ago

I just rebuilt all of my synApps tree with the head of base 7.0 and there were no other problems.