#2 MCPP can't parse constant expressions

closed-rejected
nobody
None
1
2007-08-28
2007-08-27
Incubos
No

test_macro.h:

#define TEST_MACRO(x,y) (x+y)

test.c:

#include "test_macro.h"
int main(void)
{
#if TEST_MACRO(0,1) > 0
int x = 0;
#endif
return 0;
}

Doesn't work, but gcc eats it.

Diagnostics:

> mcpp test.c
test.c:0: warning: Unknown encoding: ru_RU
#line 1 "test.c"
#line 1 "test_macro.h"
#line 2 "test.c"

int main(void) {
test.c:4: error: Operator "/" in incorrect context
macro "TEST_MACRO" defined as: #define TEST_MACRO(x,y) (x+y) /* test_macro.h:1 */
from test.c: 4: #if TEST_MACRO(0,1) > 0
#line 7 "test.c"
return 0;
}
1 error in preprocessor.

Discussion

  • Incubos

    Incubos - 2007-08-27
    • priority: 5 --> 9
     
  • Kiyoshi Matsui

    Kiyoshi Matsui - 2007-08-27

    Logged In: YES
    user_id=1509677
    Originator: NO

    I have just tested your sample by mcpp V.2.6.4 on Linux and got the
    expected result as follows. (The GCC-specific-build also shows almost
    the same result.)

    What version and what build of mcpp on what platform are you using?

    ----------------------------------------------------
    $ mcpp -v test.c
    MCPP V.2.6.4 (2007/05) compiler-independent-build compiled by GCC V.4.1
    Include paths are as follows --
    /usr/local/include/
    /usr/include/
    End of include path list.
    #line 1 "test.c"
    #line 1 "test_macro.h"
    #line 2 "test.c"
    int main(void)
    {

    int x = 0;

    return 0;
    }

     
  • Incubos

    Incubos - 2007-08-27
    • status: open --> closed-rejected
     
  • Incubos

    Incubos - 2007-08-27

    Logged In: YES
    user_id=1876655
    Originator: YES

    Thank you. We've been mistaken. We try to add semantic commentaries about macros expanded into the output preprocessed source code. What is the right way to do it?

     
  • Kiyoshi Matsui

    Kiyoshi Matsui - 2007-08-28

    Logged In: YES
    user_id=1509677
    Originator: NO

    Hello Promak,

    Are you trying to add some /* comment */ into the text which is just
    undergoing preprocess when macros are expanded?

    It is very hard to implement, because preprocessing converts a comment
    into one space in translation phase 3, and all the processing after this
    phase (i.e. processing of directives and expansion of macros) are done
    on the text without any comment.

    The current V.2.7-prerelease of mcpp, which I committed into 'trunk' of
    SVN repository yesterday, has -K option to fully annotate locations of
    macro calls embedded in comments. This mode does not insert comment
    while expanding macro, instead inserts some magic character sequence,
    and converts it to comment in later phase.

     
  • Incubos

    Incubos - 2007-08-28
    • priority: 9 --> 1
     
  • Incubos

    Incubos - 2007-08-28

    Logged In: YES
    user_id=1876655
    Originator: YES

    Hello, Kiyoshi Matsui!

    Yes, i am trying to add some /* ... */ comments containing annotations of macros being expanded. I've written you a letter. Thank you for your explanations.

     
  • Kiyoshi Matsui

    Kiyoshi Matsui - 2007-08-28

    Logged In: YES
    user_id=1509677
    Originator: NO

    Hello Vadim,

    The specification of -K option is explained at: doc/mcpp-manual.html#2.4
    and #3.5.8.

    I have sent the above e-mail in response to your e-mail. But, it returned
    on error saying "does not like recipient".

     
  • Incubos

    Incubos - 2007-08-28

    Logged In: YES
    user_id=1876655
    Originator: YES

    Hello Kiyoshi,

    Thank you for your help. Don't know why e-mail doesn't work. I've sent your e-mail from another mail-server.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks