missing #endif problem

Discussion in 'C Programming' started by mohan, Jan 16, 2006.

  1. mohan

    mohan Guest

    Hi All,

    I have large file coded consisting of function implemented in c.
    This function consissts of #if macro and corresponding. And somewhere
    in the function i am missing to put #endif , Is there any utility to find it
    out
    I get syntax error

    for example

    #define XXX 1
    void f()
    {
    #if XXX

    }

    int main()
    {
    f();
    return 0;
    }

    I get here syntax error in the function f();

    Is there any way to find out instead of doing manually

    TIA


    Mohan
     
    mohan, Jan 16, 2006
    #1
    1. Advertising

  2. mohan wrote:
    > Hi All,
    >
    > I have large file coded consisting of function implemented in c.


    You'll probably want to re-factor this large function into several
    shorter ones. Having large functions is generally (always?) a bad idea.

    > This function consissts of #if macro and corresponding.


    "And corresponding" what? I guess #endif? But it doesn't...

    > And somewhere
    > in the function i am missing to put #endif , Is there any utility to find it
    > out


    If it's missing, you can't find it out, can you? If you meant "find out
    where it should have been" then, doesn't it depend on what exactly you
    want to achieve with your #if/#endif section? There'd be no utility to
    tell you that (high level/detailed design document could be a starting
    point).

    > I get syntax error
    >
    > for example
    >
    > #define XXX 1
    > void f()
    > {
    > #if XXX
    >


    For example, here would be a good place to put your #endif, if you
    wanted your function to be empty (do nothing) if XXX is defined as 0.
    Just before the closing brace:

    #endif /* XXX */
    > }
    >
    > int main()
    > {
    > f();
    > return 0;
    > }
    >
    > I get here syntax error in the function f();


    As you well should, since you're missing an #endif...

    >
    > Is there any way to find out instead of doing manually


    Again, find out what, exactly? Where to put the #endif? See comments above.

    >
    > TIA
    >
    >
    > Mohan
    >
    >


    Cheers

    Vladimir

    --
    My e-mail address is real, and I read it.
     
    Vladimir S. Oka, Jan 16, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWFya04=?=

    <% if %> ... <% endif%>

    =?Utf-8?B?TWFya04=?=, Jun 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    600
    Random
    Jun 1, 2005
  2. prettysmurfed
    Replies:
    3
    Views:
    10,422
    MPBroida
    Oct 24, 2003
  3. boki

    #if #endif ?

    boki, Sep 13, 2004, in forum: C++
    Replies:
    6
    Views:
    2,639
    David Lindauer
    Sep 15, 2004
  4. Christopher M. Lusardi
    Replies:
    1
    Views:
    432
    Victor Bazarov
    Nov 19, 2004
  5. Christopher M. Lusardi
    Replies:
    1
    Views:
    367
    Victor Bazarov
    Nov 19, 2004
Loading...

Share This Page