E
E
emashev2020-07-07 23:33:11
C++ / C#
emashev, 2020-07-07 23:33:11

How to remake a function for gcc 9?

There is an ancient application, I'm trying to build under the latest version of alpine with gcc 9.
Thread model: posix
gcc version 9.3.0 (Alpine 9.3.0) I


won some errors, I messed up on this one:
When trying to build, an error occurs on this file:
https ://github.com/muggot/openmcu/blob/master/libs...

Specifically in these functions:

PInt64 PString::AsInt64(unsigned base) const
{
  char * dummy;
  return strtoq(theArray, &dummy, base);
}

PUInt64 PString::AsUnsigned64(unsigned base) const
{
  char * dummy;
  return strtouq(theArray, &dummy, base);


osutil.cxx: In member function 'PInt64 PString::AsInt64(unsigned int) const':
osutil.cxx:451:10: error: 'strtoq' was not declared in this scope; did you mean 'strtok'?
  451 |   return strtoq(theArray, &dummy, base);
      |          ^~~~~~
      |          strtok
osutil.cxx: In member function 'PUInt64 PString::AsUnsigned64(unsigned int) const':
osutil.cxx:457:10: error: 'strtouq' was not declared in this scope; did you mean 'strtoul'?
  457 |   return strtouq(theArray, &dummy, base);
      |          ^~~~~~~
      |          strtoul

}


Ok, I change - as the compiler suggests:

PInt64 PString::AsInt64(unsigned base) const
{
  char * dummy;
  return strtok(theArray, &dummy, base);
}

PUInt64 PString::AsUnsigned64(unsigned base) const
{
  char * dummy;
  return strtoul(theArray, &dummy, base);
}


osutil.cxx: In member function 'PInt64 PString::AsInt64(unsigned int) const':
osutil.cxx:451:27: error: cannot convert 'char**' to 'const char*'
  451 |   return strtok(theArray, &dummy, base);
      |                           ^~~~~~
      |                           |
      |                           char**
In file included from /usr/include/fortify/string.h:22,
                 from /tmp/openmcu/libs/ptlib/include/ptlib/object.h:489,
                 from /tmp/openmcu/libs/ptlib/include/ptlib/contain.h:257,
                 from /tmp/openmcu/libs/ptlib/include/ptlib.h:161,
                 from osutil.cxx:238:
/usr/include/string.h:50:33: note:   initializing argument 2 of 'char* strtok(char*, const char*)'
   50 | char *strtok (char *__restrict, const char *__restrict);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~


How can you win?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Zhilin, 2020-07-07
@emashev

Replace strtoqwith strtoll, strtouqwith strtoull.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question