rogelah
asked on
Using 'pair' Template Generates 'Error: Use ";" to terminate declarations.'
Converting from C++ 4.2 on Solaris to C++ 5.4. Output from compile script and source are below.
Compile script --
(cd timeZone ; make libs )
CC -c -DSVR4 -mt -DPAGE_COUNT_TRANSITION_PH ASE=1 -DMCP6 +w -I/bld2/mcpbld/xsi-6.14.1/ xsilib/inc lude -I../include -I/bld2/mcpbld/xsi-6.14.1/ include -I/bld2/mcpbld/xsi-6.14.1/ include/ob jects -I/bld2/mcpbld/xsi-6.14.1/ mcp/includ e -I/bld2/mcpbld/xsi-6.14.1/ include -I/bld2/mcpbld/xsi-6.14.1/ include/ob jects -I/home/sybase/sybase11.1. 1/include -library=iostream -library=Cstd -g -g timeZone.c -o timeZone.o
"/bld2/mcpbld/xsi-6.14.1/x silib/incl ude/copy_d ial_digits .h", line 51: Error: Use ";" to terminate declarations.
1 Error(s) detected.
Source code --
#ifndef __cplusplus
#include <limits.h>
#include <ctype.h>
#include "pair.h"
#else
#include <limits>
#include <utility>
using namespace std
#include <ctype.h>
#endif
#ifndef __cplusplus
inline pair<unsigned char*,unsigned char>
#else
pair<unsigned char*,unsigned char>
#endif
copy_dial_digits(char* destination,
const char* source,
char* terminators,
int max_chars = 63)
{
static pair<unsigned char*,unsigned char> return_value =
pair<unsigned char*,unsigned char>((unsigned char*)NULL,'\0');
unsigned char* dp = (unsigned char*)destination;
unsigned char* sp = (unsigned char*)source;
//
// If one or more terminator characters are specified, find the first occurrance
// of one of them after the first digit, and mark it as the stopping point.
//
unsigned char* tp = NULL;
if(terminators)
{
//
// The terminator must be preceeded by at least one digit.
//
char* fd = (char *)strpbrk(source,"01234567 89");
if(fd)
{
int sl = strcspn(fd,terminators);
if(sl) // (*fd is a digit)
{
tp = sp+sl+(fd-source);
}
}
}
while(*sp &&
(tp ? (sp < tp) : true) &&
((dp-(unsigned char*)destination) < max_chars) )
{
if(isdigit(*sp))
*dp++ = *sp;
sp++;
}
return_value.second = *sp;
return_value.first = sp;
*dp = NULL;
return return_value;
}
Compile script --
(cd timeZone ; make libs )
CC -c -DSVR4 -mt -DPAGE_COUNT_TRANSITION_PH
"/bld2/mcpbld/xsi-6.14.1/x
1 Error(s) detected.
Source code --
#ifndef __cplusplus
#include <limits.h>
#include <ctype.h>
#include "pair.h"
#else
#include <limits>
#include <utility>
using namespace std
#include <ctype.h>
#endif
#ifndef __cplusplus
inline pair<unsigned char*,unsigned char>
#else
pair<unsigned char*,unsigned char>
#endif
copy_dial_digits(char* destination,
const char* source,
char* terminators,
int max_chars = 63)
{
static pair<unsigned char*,unsigned char> return_value =
pair<unsigned char*,unsigned char>((unsigned char*)NULL,'\0');
unsigned char* dp = (unsigned char*)destination;
unsigned char* sp = (unsigned char*)source;
//
// If one or more terminator characters are specified, find the first occurrance
// of one of them after the first digit, and mark it as the stopping point.
//
unsigned char* tp = NULL;
if(terminators)
{
//
// The terminator must be preceeded by at least one digit.
//
char* fd = (char *)strpbrk(source,"01234567
if(fd)
{
int sl = strcspn(fd,terminators);
if(sl) // (*fd is a digit)
{
tp = sp+sl+(fd-source);
}
}
}
while(*sp &&
(tp ? (sp < tp) : true) &&
((dp-(unsigned char*)destination) < max_chars) )
{
if(isdigit(*sp))
*dp++ = *sp;
sp++;
}
return_value.second = *sp;
return_value.first = sp;
*dp = NULL;
return return_value;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER