| In "common mode" (aka K&R C), which is currently the default for DEC C on UNIX,
preprocessor directive *must* begin in column 1. That is, the # must be in
column1, but you may indent the code if you like by adding spaces after the #.
We describe some of these differences in a -std0 to -std Migration Guide, which
is online at http://www.zk3.dec.com/decc/doc/std-migration.html . I've included
the pertenent section below.
Unless your code relies on old style (K&R) (mis)features, you might try
compiling your code with -std.
Hope it helps.
-Jeff
Preprocessor Directives Versus # Comments
In -std0 mode (but not -std mode) cpp directives must begin in column 1.
If a # is not in column 1 and is the first non-whitespace token on a
line, that line is lexed as a # comment. Consider
int main () {
#define printf puts
printf("Hello world\n");
}
cc -E -std0 will generate
int main () {
#define printf puts
printf("Hello world\n");
}
cc -E -std will generate
int main () {
puts("Hello world\n");
}
For a full compile, cc -std0 will generate this warning message
# not in column 1 is ignored, skipping to end of line.
For a full compile, cc -std will simply generate an executable.
This is mostly an issue for .s files and .s files will still be
preprocessed in -std0 mode.
|
|
% cat t.c
#ifndef __STDC__
# define MODE K&R
#endif
#ifdef __STDC__
#define MODE ansi
#endif
mode is MODE
// In the -std0 case, note that non-column 1 directives are ignored.
% cc -E t.c
# 1 "t.c"
#ifdef __STDC__
#define K&R ansi
#endif
mode is K&R
// In the -std/-std1 case, either is acceptable.
% cc -E t.c -std
# 1 "t.c"
mode is ansi
%
|