missing #endif problem

M

mohan

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
 
V

Vladimir S. Oka

mohan said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top