weixin_39822993 2020-11-30 11:25
浏览 0

Macro expansion in #include

Originally reported on Google Code with ID 67


What steps will reproduce the problem?  Give the *exact* arguments passed
to include-what-you-use, and attach the input source file that gives the
problem (minimal test-cases are much appreciated!)

consider main.cpp :
#define CSTDLIB <cstdlib>
#include CSTDLIB

then try to compile :
> include-what-you-use main.cpp


What is the expected output?
>main.cpp should add these lines:
>
>main.cpp should remove these lines:
>- #include <cstdlib>  // lines 2-2
>
>The full include-list for main.cpp:
>---

What do you see instead?
>iwyu_lexer_utils.cc:84: Assertion failed: false && "Unexpected token being #included"
>Stack dump:
>0.      main.cpp:2:2: current parser token 'include'
>Aborted

What version of the product are you using? On what operating system?
svn trunk r349

Please provide any additional information below.
For instance this prevents analyzing any code depending on Boost because of boost/config.hpp
being included
http://www.boost.org/doc/libs/1_49_0/boost/config.hpp
</cstdlib></cstdlib>

Reported by chatelet.guillaume on 2012-03-31 09:51:23

该提问来源于开源项目:include-what-you-use/include-what-you-use

  • 写回答

16条回答 默认 最新

  • weixin_39822993 2020-11-30 11:25
    关注
    
    Sorry for the late reply -- I've moved on from clang-work (in fact, from C++ in general),
    so I'm afraid I won't be very helpful for solving problems like this.
    
    That said, I could have sworn there was a test for computed includes in tests/badinc.cc.
     Do those tests pass for you?  If so, I wonder what is different here.  Maybe you can
    run iwyu in the debugger to try to figure out what's going on.
    

    Reported by csilvers on 2012-04-20 01:35:01

    评论

报告相同问题?