Menu

"-C" fails with single-line comments ...

2009-01-07
2013-05-28
  • Oliver Schneider

    Hi,

    and first of all thanks for a great tool. This tool is really helpful. I am currently creating a documentation tool for some internal headers and being able to run a preprocessor over it like this is really convenient, especially since the documentation tool is supposed to work on different platforms and MCPP works on all of them.

    When using it, I noted there seems to be an issue with single-line comments (C++/C99 comments) when they are behind an indented line with a member declaration inside a struct.

    Example:

    ------------------------
    typedef _x
    {
        int y; // Comment 1
        int z; // Comment 2
    } x;
    ------------------------

    will yield (with the -C command line switch):

    ------------------------
    typedef _x
    {
    // Comment 1    int y;
    // Comment 2    int z;
    } x;
    ------------------------

    Is there any way to mitigate this? I am currently using "-@std".

    Thanks again,

    // Oliver

     
    • Oliver Schneider

      Sadly SF.net stripped the blank spaces before the member declarations. Also, these blank spaces would appear *behind* the comments in the result provided below.

      // Oliver

       
    • Kiyoshi Matsui

      Kiyoshi Matsui - 2009-01-08

      Thanks for the bug reporting!

      mcpp V.2.7 and V.2.7.1 have the same bug with V.2.7.2.  Please apply the following patch.  This is a patch for V.2.7.2.  The line numbers differ from it on V.2.7 or V.2.7.1.

      *** support.c.orig  2008-06-10 17:32:33.000000000 +0900
      --- support.c   2009-01-08 13:32:48.000000000 +0900
      ***************
      *** 1722,1727 ****
      --- 1722,1728 ----
                            sp -= 2;
                            while (*sp != '\n')     /* Until end of line    */
                                mcpp_fputc( *sp++, OUT);
      +                     wrong_line = TRUE;
                        }
                        goto  end_line;
                    default:                        /* Not a comment        */

       
    • Oliver Schneider

      Thanks for the fast response. It's greatly appreciated.

      // Oliver

       
    • Oliver Schneider

      A precompiled (COMPILER=INDEPENDENT) binary for Win32 with the fix can be found here, until the next version that incorporates the patch gets released: http://assarbad.net/stuff/temp/mcpp_2.7.2_slcomm_patch.rar

      // Oliver

       
    • Kiyoshi Matsui

      Kiyoshi Matsui - 2009-01-17

      Thanks for the upload.

       
    • Oliver Schneider

      BTW: I just noticed that the patch will not work. I think it requires an additional line break such as in other places. I.e.:

      *** support.c.orig 2008-06-10 17:32:33.000000000 +0900
      --- support.c 2009-01-08 13:32:48.000000000 +0900
      ***************
      *** 1722,1727 ****
      --- 1722,1728 ----
      sp -= 2;
      while (*sp != '\n') /* Until end of line */
      mcpp_fputc( *sp++, OUT);
      + mcpp_fputc( '\n', OUT);
      + wrong_line = TRUE;
      }
      goto end_line;
      default: /* Not a comment */

      At least this will yield a result such as this for above example:
      typedef _x
      {
      // Comment 1
      int y;
      // Comment 2
      int z;
      } x;

      // Oliver

      PS: I'll upload the patched binary once you provide feedback whether this change is logical to you or has other repercussions.

       
    • Kiyoshi Matsui

      Kiyoshi Matsui - 2009-01-20

      Sorry for my mistake.
      The bug appears when -P option is specified along with -C.
      Your patch is correct.  Thanks.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.