Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 359
roymustang86 Avatar asked Jan 24 '26 20:01

roymustang86


2 Answers

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.

like image 170
Pete Becker Avatar answered Jan 26 '26 12:01

Pete Becker


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

like image 20
Rost Avatar answered Jan 26 '26 12:01

Rost



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!