I've been tasked with setting up a Debian server that will provide a service using TTK (trigger toolkit).
However, the software seems to be from 1997, and unmaintained, and wont compile with GCC (g++
) by default (v4.7.2).
Some of the errors originated from not specifying the std
namespace, and I've fixed those.
However, I'm having problems with a class that seems to be included in the software for hardware compatibility, specifically, its read
functions.
The class, from what I can understand, is supposed to abstract endianness of the hardware (or something of a similar nature):
public:
Architecture()
{
short y = 256;
short *x=&y;
alpha_byte_ordering = ( *( (char*) (x) + 1) ) == 1 ? 1 : 0;
if (alpha_byte_ordering)
fprintf(stderr, "Architecture: detected alpha byte ordering.\n");
else fprintf(stderr, "Architecture: detected non-alpha byte ordering.\n");
}
int read(istream &is, short *s)
{
if (!is.read(s, sizeof(short))) return 0;
if (!alpha_byte_ordering) reverse_byte_order(s);
return 1;
}
There are many other overloaded read
functions, and they all spit out errors such as this one:
Architecture.H: In member function ‘int Architecture::read(std::istream&, short int*)’:
Architecture.H:31:34: error: no matching function for call to ‘std::basic_istream<char>::read(short int*&, long unsigned int)’
It seems as if this code was ignorant of the C++ standard which I think specifies that istream::read
should accept a character array (char *
), not varying types such as short *
and double *
(I actually read that here, not in the standard).
Am I interpreting this code incorrectly? Has this aspect of the standard changed since 1997? Or was this code simply non-functional to begin with (I highly doubt this since there are papers written about it)?
Lastly, how can I fix this? Casting s
to char *
C-style seems to remove the errors but I'm not sure whether it fixes the problem or not.