Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Old compiler issues again

Having given up on the gcc 2.95.2, I tried xlC

>xlC -v
exec: /usr/bin/pg(/usr/bin/pg,/usr/lib/nls/msg/en_US/vacpp.help,NULL)
VisualAge C++ Professional / C for AIX Compiler, Version 5

surprisingly, most of the code actually compiled except for the following:

ld: 0711-317 ERROR: Undefined symbol: TypeBase::MAXLINELENGTH
ld: 0711-317 ERROR: Undefined symbol: TypeBase::BLANKSPACE

however, it is defined in the .h file. As a work around, I put the actual values in place of the constant names and sure enough, it compiled.

regarding static variables definitions in the .h file, am I using something that was not ansi standard back then?

#ifndef CARDTYPES_H_
#define CARDTYPES_H_

using namespace std;

class TypeBase
{
private:
bool shortFormat;
string entireLine;
long fieldWidth;
int dataFieldSortingIndex;
public:
void setFieldWidth(string & data);
string mergeLines(list<string> &);
string name;
static const long MAXLINELENGTH = 80;
static const long BLANKSPACE = -99999;
friend class TypeCELAS1;
[1163 byte] By [rssmps] at [2007-11-11 7:50:23]
# 1 Re: Old compiler issues again
No, your code if fully ISO complaint. Yoru compiler is simply way too old and incompliant.
The in class initailization of const static variables of integral types was added to C++ more than a decade ago, but old compilers still don't support it. As a workaround, you need to define (and initialize) these variables outside the class, but not in the .h file because this might cause multiple definition problems.
Danny at 2007-11-11 21:01:54 >