roymustang86
roymustang86

Reputation: 8573

Porting an old C++ code from Solaris to Linux

I am just wondering if this type of declaration is allowed in C++

  static nextUnassignedTableID = 0; 
  static nextUnassignedFieldID = TSFID_MINIMUM_USER_TSFID;

It doesn't complain about anything on Solaris/AIX.

But, on Red Hat Enterprise Linux, it complains about

 TSIDConverter.cpp(637): error #303: explicit type is missing ("int" assumed)
 static nextUnassignedTableID = 0; 

 TSIDConverter.cpp(638): error #303: explicit type is missing ("int" assumed)
 static nextUnassignedFieldID = TSFID_MINIMUM_USER_TSFID;

On Linux, I am using Intel 11.1 compiler with the command icpc -m32.

Should I include other libs in order for it to compiler, or is this style of declaration not allowed anymore?

Upvotes: 3

Views: 611

Answers (2)

Pete Becker
Pete Becker

Reputation: 76370

It's pretty much never been allowed. The first C++ standard disallowed the C "implicit int" rule; C99 also got rid of that rule. But the rule is simple, and fixing the code is also simple: just stick int in wherever the compiler complains. Tedious, perhaps, but straightforward.

Upvotes: 8

Rost
Rost

Reputation: 9089

Default int is not allowed in C++, you need to fix this code and set an explicit int type for variables.

Upvotes: 1

Related Questions