epics-base / pvDataCPP

pvDataCPP is an EPICS V4 C++ module
https://epics-base.github.io/pvDataCPP/
Other
6 stars 16 forks source link

Questionable type detection in parseToPOD.cpp #95

Open anjohnson opened 3 months ago

anjohnson commented 3 months ago

This code in src/misc/parseToPOD.cpp breaks 64-bit RTEMS ARM builds (according to @kiwichris), and might be questionable on Windows and Apple too:

// need to use "long long" when sizeof(int)==sizeof(long)
#if (ULONG_MAX == 0xfffffffful) || defined(_WIN32) || defined(__rtems__) || defined(__APPLE__)
#define NEED_LONGLONG
#endif

Build errors:

../../src/misc/parseToPOD.cpp: In function 'void epics::pvData::detail::parseToPOD(const char*, int64_t*)':
../../src/misc/parseToPOD.cpp:137:38: error: invalid conversion from 'int64_t*' {aka 'long int*'} to 'long long int*' [-fpermissive]
  137 |     int err = epicsParseLongLong(in, out, 0, NULL);
      |                                      ^~~
      |                                      |
      |                                      int64_t* {aka long int*}
../../src/misc/parseToPOD.cpp:31:48: note:   initializing argument 2 of 'int epicsParseLongLong(const char*, long long int*, int, char**)'
   31 | epicsParseLongLong(const char *str, long long *to, int base, char **units)
      |                                     ~~~~~~~~~~~^~
../../src/misc/parseToPOD.cpp: In function 'void epics::pvData::detail::parseToPOD(const char*, uint64_t*)':
../../src/misc/parseToPOD.cpp:146:39: error: invalid conversion from 'uint64_t*' {aka 'long unsigned int*'} to 'long long unsigned int*' [-fpermissive]
  146 |     int err = epicsParseULongLong(in, out, 0, NULL);
      |                                       ^~~
      |                                       |
      |                                       uint64_t* {aka long unsigned int*}
../../src/misc/parseToPOD.cpp:62:58: note:   initializing argument 2 of 'int epicsParseULongLong(const char*, long long unsigned int*, int, char**)'
   62 | epicsParseULongLong(const char *str, unsigned long long *to, int base, char **units)
      |                                      ~~~~~~~~~~~~~~~~~~~~^~

I had no problems building the RTEMS-uC5282 on RTEMS-4.10.2 with the || defined(__rtems__) removed, but that's all I've checked.