User Tools

Site Tools


warn_pragmas_1.htm
Navigation:  Advanced Topics > Legacy Project System Reference >====== Warn #pragmas ====== Previous pageReturn to chapter overviewNext page

#pragmas with the class name warn control the generation of compiler warnings. These #pragmas are only available under the project language and C/C++.

The warnings given by SoftVelocity C and C++ help you to check, as far as possible, common coding mistakes. Since no compiler can determine your intentions, you may get warnings even if your code is correct. Your code may generate some warnings more than others, so SoftVelocity allows you to customize which warning checks are performed.

You can set each of the warning options to on, off, or err. When on, SoftVelocity checks the code for that warning and reports the problem, but the problem does not stop the compile or linking. When off, SoftVelocity ignores the warning. When err, SoftVelocity checks the code for the warning, reports the problem, and does not allow linking until you have fixed the problem.

NoteBox.jpg SoftVelocity C and C++ check the code and produce a warning for a good reason. Indeed, to use your non-ANSI C code, SoftVelocity C uses a minimal set of warning messages by default. You should, therefore, think twice before turning off any of the default warning messages. We advise that you keep all the warnings either on or err.

The following warn #pragmas are available:

#pragma warn(wacc ⇒ on | off | err)

#pragma warn(wait ⇒ on | off | err)

#pragma warn(wall ⇒ on | off | err)

#pragma warn(watr ⇒ on | off | err)

#pragma warn(wcic ⇒ on | off | err)

#pragma warn(wcld ⇒ on | off | err)

#pragma warn(wclt ⇒ on | off | err)

#pragma warn(wcne ⇒ on | off | err)

#pragma warn(wcor ⇒ on | off | err)

#pragma warn(wcrt ⇒ on | off | err)

#pragma warn(wdel ⇒ on | off | err)

#pragma warn(wdne ⇒ on | off | err)

#pragma warn(wdnu ⇒ on | off | err)

#pragma warn(wetb ⇒ on | off | err)

#pragma warn(wfnd ⇒ on | off | err)

#pragma warn(wftn ⇒ on | off | err)

#pragma warn(wnid ⇒ on | off | err)

#pragma warn(wnre ⇒ on | off | err)

#pragma warn(wnrv ⇒ on | off | err)

#pragma warn(wntf ⇒ on | off | err)

#pragma warn(wovl ⇒ on | off | err)

#pragma warn(wovr ⇒ on | off | err)

#pragma warn(wpcv ⇒ on | off | err)

#pragma warn(wpic ⇒ on | off | err)

#pragma warn(wpin ⇒ on | off | err)

#pragma warn(wpnd ⇒ on | off | err)

#pragma warn(wpnu ⇒ on | off | err)

#pragma warn(wprg ⇒ on | off | err)

#pragma warn(wral ⇒ on | off | err)

#pragma warn(wrfp ⇒ on | off | err)

#pragma warn(wsto ⇒ on | off | err)

#pragma warn(wtxt ⇒ on | off | err)

#pragma warn(wubd ⇒ on | off | err)

#pragma warn(wvnu ⇒ on | off | err)

NoteBox.jpg

A pragma can be used in the Project language, C++ code, Modula-2 code, or Clarion code. Some only work in certain places. A 'P' to the right of the pragma indicates it can be used in the Project language, a 'C' indicates it can be used in C++ code, a 'M' indicates it can be used in Modula-2 code, and a 'W' indicates that it can be used in Clarion code (CLW files).

#pragma warn(wall ⇒ on | off | err)    cp

This #pragma affects the settings of all the warnings. If set to on or err, all warnings will be enabled.

#pragma warn(wpcv ⇒ on | off | err)    cp

Pointer conversion. When on or err, the compiler checks for a conversion between two incompatible pointer types, or between a pointer and an integral type. The default setting is on.

#pragma warn(wdne ⇒ on | off | err)    cp

Declaration has no effect. When on or err, the compiler checks for a declaration that has no meaning, for example, long int;. A declaration should contain a variable declarator, a structure or union tag, or members of an enumeration. The default setting is on.

#pragma warn(wsto ⇒ on | off | err)    cp

Storage class redeclared. When on or err, the compiler checks that you have not declared the same variable differently within your program. For example:

int x; /* External linkage */

static int x; /* Internal linkage */

The static storage class always takes preference. The default setting is on.

#pragma warn(wtxt ⇒ on | off | err)    cp

Unexpected text in preprocessor command. When on or err, the compiler checks for a new line character terminating a preprocessor command. The default setting is on.

#pragma warn(wprg ⇒ on | off | err)    cp

Unknown #pragma. When on or err, the compiler checks for foreign #pragmas or mistakes in SoftVelocity C #pragmas. If you are only creating code using SoftVelocity C or C++ #pragmas, you should switch this warning to either on or err. The default setting is on.

#pragma warn(wfnd ⇒ on | off | err)    cp

Function not declared. When on or err, the compiler checks for functions that have been called but not declared. If these functions occur, SoftVelocity C assumes that the function is an extern function returning an int. The default setting is off.

#pragma warn(wpnd ⇒ on | off | err)    cp

Function prototype not declared. When on or err, the compiler checks whether a function has a prototype associated with it. Prototypes are important to SoftVelocity, since it can not do much type checking without them. You should, therefore, declare prototypes for all functions. It is best to keep this warning on or err. The default setting is off.

#pragma warn(wnre ⇒ on | off | err)    cp

No expression in return statement. When on or err, the compiler checks for a return value in a non-void function. You should keep this warning off if you are compiling some old style C code without prototypes. The default setting is off.

#pragma warn(wnrv ⇒ on | off | err)    cp

No return value in function. When on or err, the compiler checks for a return statement in a non-void function. The default setting is off.

#pragma warn(watr ⇒ on | off | err)    cp

Different const attributes. When on or err, the compiler checks whether a function that expects a pointer to a variable gets a pointer to a constant. The default setting is on.

#pragma warn(wftn ⇒ on | off | err)    cp

Far to near pointer conversion. When on or err, the compiler checks for conversion of a 32-bit far pointer to a 16-bit near pointer. The default setting is on.

#pragma warn(wntf ⇒ on | off | err)    cp

Near to far pointer conversion. When on or err, the compiler checks for conversion of a 16-bit near pointer to a 32-bit far pointer. The default setting is on.

#pragma warn(wubd ⇒ on | off | err)    cp

Possible use of variable before assignment. When on or err, the compiler checks that you have used a local variable before you have given it a value. SoftVelocity checks this warning with a simple scan through the function, which can cause gotos and the like to generate false warnings.

#pragma warn(wpnu ⇒ on | off | err)    cpw

Parameter never used in function. When on or err, the compiler checks for a parameter that the code never uses, so declaration of dummy parameters generates warnings. The default setting is off.

#pragma warn(wdnu ⇒ on | off | err)    cpw

Variable declared but never used. When on or err, the compiler checks whether a local variable has been declared but never used in the function. The default setting is on.

#pragma warn(wcne ⇒ on | off | err)    cp

Code has no effect. When on or err, the compiler checks statements and the left operand in a comma expression to see if they have no effect. The default setting is on. For example:

x y; /* expression has no effect */

f, x; /* left operand has no effect */

#pragma warn(wcld ⇒ on | off | err)    cp

Conversion may lose significant digits. When on or err, the compiler checks for a conversion from long or unsigned long to int or unsigned int. The default setting is on.

#pragma warn(wait ⇒ on | off | err)    cp

Assignment in test expression. When on or err, the compiler checks for a possible mistyping of the C equality (==) operator. The equality operator contains two =. For example:

if (x=y) printf(“X equals Y”); /* is a mistake */

The default setting is on.

#pragma warn(wetb ⇒ on | off | err)    cp

Value of escape sequence is too large. When on or err, the compiler checks that an escape sequence is in the range 0 to 255. The default setting is on.

#pragma warn(wcor ⇒ on | off | err)    cp

Value of constant is out of range. When on or err, the compiler checks whether an integer constant is in the range of an unsigned long, or a floating point constant is in the range of a long double. The default setting is on.

#pragma warn(wclt ⇒ on | off | err)    cp

Constant is long. When on or err, the compiler checks for an integral constant that has type long because of its value but does not have an L suffix. The default setting is off.

#pragma warn(wral ⇒ on | off | err)    cp

Returns address of local variable. When on or err, checks for a return statement that returns the address of a local variable. This causes a problem because C reclaims the variable storage on completion of the function. The pointer, therefore, points at undefined data. The default setting is on.

#pragma warn(wpin ⇒ on | off | err)    cp

Default type promotion on parameter. When on or err, the compiler compares the declaration of a parameter in an old-style function definition with the prototype for incompatible argument promotions. For example:

int func(char); /* parameter declared as char */

int func(IntegerByPromotion);

char IntegerByPromotion;

      /* INCOMPATIBLE */

{

}

NoteBox.jpg This is a violation of the ANSI C standard regarding compatible function declarations.The default setting is on.

#pragma warn(wpic ⇒ on | off | err)    cp

Parameter list inconsistent with previous call. This warning is issued if a parameter declaration is incompatible with the corresponding parameter in a previous function declaration. The default setting is on.

#pragma warn(wnid ⇒ on | off | err)    cp

Address for local variable not in DGROUP. When on or err, the compiler checks that a local variable does not have its address taken in small model, when using #pragma data(ss_in_dgroup ⇒ off). The default setting is on.

#pragma warn(wrfp ⇒ on | off | err)    cp

Function redeclared with fixed parameters. When on or err, the compiler checks for a prototype with a variable number of arguments, but the corresponding function definition specifies a fixed number of arguments. This will work in SoftVelocity C, but it is a violation of the ANSI C rules for compatible function declarations, and therefore, not portable. The default setting is on.

#pragma warn(wvnu ⇒ on | off | err)    cp

Local variable never used. When on or err, the compiler checks whether you declare a local variable and assign it a value but never use it. The default setting is on.

#pragma warn(wovr ⇒ on | off | err)    cp

Overflow in constant expression. This warning is issued when a constant integer expression overflows. The default setting is on.

#pragma warn(wacc ⇒ on | off | err)    cp

Default access specifier used for base class. This warning is issued if a base class specification does not have an access specifier and the default access is used (i.e. public for a struct and private for a class). The default setting is on.

#pragma warn(wdel ⇒ on | off | err)    cp

Expression in delete[] is obsolete. This warning is issued if an expression is specified in the square brackets of a delete expression. The expression is ignored. This is obsolete C usage. The default setting is on.

#pragma warn(wovl ⇒ on | off | err)    cp

Keyword 'overload' is not required. This warning is issued if the keyword overload is specified in C. The use of this keyword is obsolete C usage. The default setting is on.

#pragma warn(wcic ⇒ on | off | err)    cp

Constant in code segment requires initialization. This warning is issued if a constant placed in the code segment requires run-time initialization, as may be the case for an object declared const in C, whose initializer is an expression, when the const_in_code #pragma is set on. This situation will lead to a protection violation in OS/2 and Window 3 protected mode applications, so const_in_code should be set off if this warning is encountered. The default setting is on.

#pragma warn(wcrt ⇒ on | off | err)    cp

Class definition as function return type, missing ';' after '}'?

This warning is issued if a class is defined in a function return type specification. Such a construct is legal, but unusual, and frequently results from omitting a semicolon between a class definition and the following function declaration. The default setting is on.

warn_pragmas_1.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1