[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2211.0. "preprocessor behavior?" by HYDRA::LNARAYAN () Thu Jun 05 1997 13:34

    Hello
    
    Why the preprocessor ignores the statements that starts with tab.
    Is there a reson for this behaviour? 
    
    Thanks In Advance
    Lakshminarayan
T.RTitleUserPersonal
Name
DateLines
2211.1-std0 vs. -std (or -std1) hehaviorDECC::SULLIVANJeff SullivanThu Jun 05 1997 13:5048
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.
2211.2-std0 vs -std exampleDECC::SULLIVANJeff SullivanThu Jun 05 1997 13:5440
% 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
% 
2211.3Thank YouHYDRA::LNARAYANThu Jun 05 1997 14:386
    Hello
    
    Thank you very much for the information and the example.
    It is a very quick response. I appreciate it.
            
    Lashminarayan