This appendix contains some of the most common pitfalls you might encounter while using DEC C Symptoms, examples, and solutions are described.
The compiler generates an "Insufficient Virtual Memory" error.
Increase the PAGEFILEQUO process quota and/or the VIRTUALPAGCNT sysgen parameter.
The compiler does not recognize expected routine entry points.
$ type main.c
main()
{
exit(1);
}
$ cc main.c
exit(1);
..^
%CC-I-IMPLICITFUNC, In this statement, the identifier
exit is implicitly declared as a function.
The compiler generates a %CC-E-NOTCOMPAT error message for seemingly correct code.
$ type main.c
void foo(short a);
void foo(a)
short a;
{}
$ cc main.c
void foo(a)
.....^
%CC-E-NOTCOMPAT, In this declaration, the type of foo is not compatible
with the types of previous declarations of foo.
This example represents a mixing of new-style function prototypes and old-style function declarations. In the following declaration, the argument a gets widened to int on entry to foo before being converted to type short:
void foo(a) short a;
Consequently the compiler detects a type mismatch. The example can be generalized to float variables, or any combination of (unsigned) char or short arguments.
void foo();
void foo(a)
short a;
{}
void foo(short a);
void foo(short a)
{}
Include-file lookups do not include the anticipated files.
By default, DEC C for OpenVMS Systems first searches the directory containing the top-level source file. Consider the following files and the #include statements they contain:
[]main.c #include "[.sub1]a.h" [.sub1]a.h #include "b.h" [.sub1]b.h "In [.sub1]" [.sub2]b.h "In [.sub2]"
Compiling with the following command includes the [.sub2]b.h header file:
cc/include=[.sub2]main.c
Specify /NESTED_INCLUDE_DIRECTORY in order to first search the directory containing the top-level source file (not the directory of the source file containing the #include directive).
VAX C extensions to the language are not accepted by the compiler.
int _align (word) w1; ....^ %CC-W-ALIGNEXT, _align is a language extension.
Compile using the /STANDARD=VAXC qualifier.
The compiler generates a ADDRCONSTEXT (warning in /STANDARD=RELAXED mode and error in /STANDARD=ANSI mode) for seemingly correct code.
$ type main.c
struct dsc$descriptor_s
{
unsigned short dsc$w_length;
unsigned char dsc$b_dtype;
unsigned char dsc$b_class;
char *dsc$a_pointer;
};
main()
{
char name[5];
struct dsc$descriptor_s name_dsc = {
sizeof(name)-1, 14, 1, name };
}
$ cc main.c
sizeof(name)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, name };
..............................................^
%CC-W-ADDRCONSTEXT, In the initializer for name_dsc.dsc$a_pointer,
"name" does not have a constant address, but occurs in a context that
requires an address constant. This is an extension of the language.
Section 3.5.7 of the ANSI Standard restricts allowable automatic aggregate initializion. The DEC C compiler does not have this restriction in /STANDARD=VAXC mode. Use any of the following solutions.
static char name[5];
#pragma __nostandard
struct dsc$descriptor_s name_dsc = {
sizeof(name)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, name };
}
#pragma __standard