include-what-you-use / include-what-you-use

A tool for use with clang to analyze #includes in C and C++ source files

Home Page:https://include-what-you-use.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

-DSYMBOL="abc" -> #define SYMBOL abc

bytefactory73 opened this issue · comments

whatever i try. in the compile settings i find the correct definition of my predefined macro
-DSYMBOL="abc"

:6:25: note: expanded from macro 'SYMBOL'
6 | #define SYMBOL abc

include-what-you-use.exe translates the define into:

#define SYMBOL abc

instead of
#define SYMBOL "abc"

how can i solve this problem? or is this a bug in the code?

regards

It's not clear to me what the eventual problem is... Can you show a slightly larger example with the code that triggers the note: expanded from macro 'SYMBOL' diagnostic, and some full include-what-you-use commands to show how the tool is started?

Also, you might want to try running clang <arguments> instead of include-what-you-use <arguments> and see if you get the same behavior. Obviously, strip out any -Xiwyu-prefixed arguments as part of that exercise.

Hi, i managed to create a demo project. i added

-DMYMACRO="abc.def.ghi" to the global settings:

image

Running command 'C:\Users\Tilo\iwyu\include-what-you-use.exe' with following arguments:
-Xiwyu --verbose=2 -Xiwyu --mapping_file="C:\Users\Tilo\iwyu\msvc.imp" -Xiwyu --max_line_length=256 -w -Wno-invalid-token-paste -fms-compatibility -fms-extensions -fdelayed-template-parsing -std=c++17 -DMYMACRO="abc.def.ghi" "@C:\Users\Tilo\AppData\Local\Temp\tmpBF1C.tmp" E:\Development\tools\include-what-you-use-macro-bug\test.cpp

E:\Development\tools\include-what-you-use-macro-bug\test.cpp:6:20: error: use of undeclared identifier 'abc'
6 | const char* str = MYMACRO;
| ^
:1:17: note: expanded from macro 'MYMACRO'
1 | #define MYMACRO abc.def.ghi
| ^

Unable to resolve include: 'stdio.h'

include-what-you-use-macro-bug.zip

I don't have access to Windows or visual studio for testing. And I don't know who maintains that Include What You Use plugin.

But what happens if you run that command in your cmd.exe console? Try googling for /D quote workarounds, and you should find ways of spelling the switch so the quotes are preserved.

@bytefactory73 Did you have any luck with this? Anything we can do from the IWYU project, or should we close this issue?

Looks like this went to sleep. Feel free to open again if something new comes up on the topic.