Author Topic: Code parser sucks for macros followed by C-style comments  (Read 5192 times)

Offline wofun

  • Single posting newcomer
  • *
  • Posts: 9
Code parser sucks for macros followed by C-style comments
« on: July 02, 2010, 10:53:19 am »
The code parser which creates the symbol database sucks if a macro declaration is followed by a C-style comment:

#define AAA whatever   /* comment#1 */
#define BBB whatever   /* comment#2 */

#define CCC whatever   /* comment#3 */

The symbol browser shows a single entry for AAA which spans the declaration of AAA and BBB.
The symbol BBB is not resolved ("go to declaration" sucks).
The symbol CCC is OK again.

No need to tell that this is more than annoying.

Seems as if the C-style comment is accidentally interpreted as line continuation.
Seems as if the empty line forces a new item.

I think this should be a pretty well known issue but the search function does not find something useful in the bug database. Should I write a new bug report? Would have to create an account just for that...
« Last Edit: July 02, 2010, 10:56:10 am by wofun »
- far from infinity - but each day a little closer -

Offline wofun

  • Single posting newcomer
  • *
  • Posts: 9
Re: Code parser sucks for macros followed by C-style comments
« Reply #1 on: July 02, 2010, 10:55:29 am »
Btw:
Same behavior on 8.02 and 10.05
Same behavior on Linux and Windows.
- far from infinity - but each day a little closer -

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code parser sucks for macros followed by C-style comments
« Reply #2 on: July 02, 2010, 11:09:42 am »
C::B do not support (well/at all) parsing of marcos and templates.
There is some work going on in a separate branch, but it is not ready for the general public.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code parser sucks for macros followed by C-style comments
« Reply #3 on: July 03, 2010, 04:20:55 am »
The code parser which creates the symbol database sucks if a macro declaration is followed by a C-style comment:

#define AAA whatever   /* comment#1 */
#define BBB whatever   /* comment#2 */

#define CCC whatever   /* comment#3 */

The symbol browser shows a single entry for AAA which spans the declaration of AAA and BBB.
The symbol BBB is not resolved ("go to declaration" sucks).
The symbol CCC is OK again.

No need to tell that this is more than annoying.

Seems as if the C-style comment is accidentally interpreted as line continuation.
Seems as if the empty line forces a new item.

I think this should be a pretty well known issue but the search function does not find something useful in the bug database. Should I write a new bug report? Would have to create an account just for that...

I will check it. I think it is not a big bug.

By the way. There is a branch about CodeCompletion in SVN repo, Someone(include me) were try to improve the Macro handling and Macro expansion.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code parser sucks for macros followed by C-style comments
« Reply #4 on: July 03, 2010, 04:50:27 am »
I just test the code in CC_BRANCH's parsertest project.

Code
#define AAA whatever   /* comment#1 */
#define BBB whatever   /* comment#2 */

#define CCC whatever   /* comment#3 */

It seems it works fine, see the log:
Code
--------------T-r-e-e--L-o-g--------------

000046. #define AAA whatever [9,9]
000047. #define BBB whatever [10,10]
000048. #define CCC whatever [12,12]


--------------L-i-s-t--L-o-g--------------

000049. preprocessor #define AAA whatever [9,9]
000050. preprocessor #define BBB whatever [10,10]
000051. preprocessor #define CCC whatever [12,12]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.