help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pre-processor commands in c-mode


From: Pascal Bourguignon
Subject: Re: Pre-processor commands in c-mode
Date: 21 Mar 2003 23:33:53 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Kevin Dziulko <dziulko@klaatu.canisius.edu> writes:

> Hello
> 
> Does any one know of a good method / setting / package for better
> handling of pre-processor commands in c-mode, specificly spacing
> and auto-indentation?
> 
> For example, if I enter the folloeing code, the #endif moves to
> the beginning of the line when I press enter after it.
> 
> int main ()
> {
>     if (x)
>     {
>         #ifdef DEBUG
>         printf("null");
> #endif
>     }
> }
> 
> Thanks for any help.
> Kevin

Of course. The normal indentation for cpp directive is column 0:

int main ()
{
    if (x)
        {
#ifdef DEBUG
            printf("null");
#endif
        }
}


Normally, cpp takes into account only directive whose '#' is in column 0.
That's why you sometimes see directives indented this way:

#ifdef COND1
#  ifdef COND2
#     ifdef COND3
#     else
#     endif
#  endif
#else
#  ifdef COND2
#  endif
#endif


-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]