Sun Studio 11 Warning raised after new compiler upgrade

Hi All,

I have an issue regarding the warning raised by new complier upgrade.

Sun Studio 11 is the product and OS is Solaris 8.The following are the warning messages after successful compilation

1. Warning: declarator required in declaration

2. Warning: Last line in file "../inc/bibbnote.h" is not terminated with a newline

Please advise me on the above issue wheather the above warnings can be ignored.

Regards

Vinoth

Message was edited by:

vinothsankar

[518 byte] By [vinothsankara] at [2007-11-26 19:16:36]
# 1

The first warning is telling you that something is wrong with a declaration. The program might not work as you intend, but the compiler cannot tell what you meant to do. If you post the offending line, I can tell you more.

A missing newline at the end of a file can result in the last line of the file being concatenated with the first line of the next file. Whether that matters depends on what is in those two lines. It is best to add the newline to the file.

clamage45a at 2007-7-9 21:29:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

I am getting the same errors...

"../util_vob/Include/../Memory/TokenCommandClass.h", line 32: Warning: declarator required in declaration.

"../util_vob/Include/../Memory/TokenCommandClass.h", line 33: Warning: declarator required in declaration.

"../util_vob/Include/../Sockets/SSLClass.h", line 32: Warning: declarator required in declaration.

The 3 affected lines (respectively) are as follows:

typedef enum CmdObjTyp { CmdObjTyp_TokenCommand, CmdObjTyp_ServerCommand };

typedef enum MemoryTyp { MemoryTyp_Command, MemoryTyp_Response };

typedef enum SSLTyp { SSLTyp_Client, SSLTyp_Server };

Any ideas?

Thanks!

chobbinsa at 2007-7-9 21:29:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

Those lines are not valid C++, since no typedef name is provided. Sun C++ accepts them as an extension, but issues a warning because the code is not valid.

Examples:

typedef int Int;

Int is declared to be a synonym for int.

typedef int;

Invalid: no name is provided as a synonym for int.

enum Foo { a, b, c};

Foo is declared to be an enumerated type with enumerators a, b, c.

Typedef Foo Bar;

Bar is declared to be a synonym for Foo

typedef enum { d, e, f } E1;

E1 is a synonym for the unnamed enumerated type with enumerators d, e, and f. This is a C style declaration, which serves no useful purpose in C++.

typedef enum E2 { g, h, i } E3;

E2 is declared to be an enumerated type with enumerators g, h, i, and a synonym E3.

typedef enum E4 { j, k, l };

Invalid declaration. No name is provided as a synonym for E4. Remove the "typedef" and you have a valid declaration of E4 as an enumerated t ype.

References: C++ Standard, sections

7.1.3 The typedef specifier

7.2 Enumeration declarations

clamage45a at 2007-7-9 21:29:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
HiI'd also add that if this is C++ code, "typedef enum" (and "typedef struct") is redundant. In C, such typedefs save you from having to type 'enum' (or 'struct'). But in C++, enum and struct are both first class types, and this is not necessary.Paul
Paul_Floyda at 2007-7-9 21:29:49 > top of Java-index,Development Tools,Solaris and Linux Development Tools...