Hi guys,
I am stuck with this piece of code for a long time.

The errors that come are:
bfs.cc: In function 'void greedyMatch()':
bfs.cc:9: error: expected initializer before '*' token

The relevant code is

#define forallXNodes(u,G) \    for(arc *bfs_ee=(G.getSource())->firstOutArc(),arc *bfs_stopA=(G.getSource())->lastOutArc(),u=bfs_ee->head(); bfs_ee <= bfs_stopA;u = (++bfs_ee)->head())

#define forallYNodes(u,G) \
    for( arc *bfs_ee=(G.getSink())->firstOutArc(),arc *bfs_stopA=(G.getSink())->lastOutArc(),u=bfs_ee->head(); bfs_ee <= bfs_stopA; u = (++bfs_ee)->head())

There is something that is wrong in these for loops.Actually the file bfs.cc where these errors are coming is the file in which these #define have been made and line 9 where an error is coming is the line where forallXnodes is written .............and hence an error is coming.......

Any help shall be appreciated............

I am using GNU g++ compiler.

Thank you!

Just looking at this very complex for loop that whole thing looks to be a for loop condition so where is the code that is executed upon each iteration?

Try breaking it down and see if thats what you expected/wanted

Try wrapping the for loop in parentheses. I also split the macro into multiple lines.

#define forallXNodes(u,G) \
    (for(arc *bfs_ee=(G.getSource())->firstOutArc(),arc *bfs_stopA=\
    (G.getSource())->lastOutArc(),u=bfs_ee->head(); bfs_ee <= bfs_stopA;u =\
    (++bfs_ee)->head()))

Thank you so much Nathan...............You rock

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.