-2

I am trying to visualize my source code preprocessed in Visual Studio, but I can't get to output anything. No error, but not any .i file in the end either.

I have seen these options for cl.exe here: How do I see a C/C++ source file after preprocessing in Visual Studio?

used /P, but after compile, their is nothing more in my project directory or subfolders.

also tried this: "preprocess current file" addin for Visual Studio? (C++ )

I have adapted the path to devenv.exe to match with my install, but I get a warning from Visual Studio, basically an help man.

Am I completely missing something? How get the preprocessed .i files?

hymced
  • 570
  • 5
  • 19
  • "basically an help man" What's that suppoused to mean? Additionally, in English question marks don't have a space before them in sentences. – tambre Dec 03 '17 at 09:56
  • @tambre yes that is probably because I am french, and we prepend a space before them, but I knew that ^^ It means it gives me a prompt explaining how to use the command with all the available options, like an help man. – hymced Dec 03 '17 at 09:58
  • I've never heard of whatever you're calling "an help man" - might be a concept exclusive to the French language (Google doesn't give me any results either). You probably mean a "help prompt", which is usually displayed by command-line tools if your command syntax is invalid. – tambre Dec 03 '17 at 10:03
  • Go to `Project Properties` ➡ `C/C++` ➡ `Preprocessor` and set `Preprocess to a file` to `Yes`. Rebuild project. Preprocessed files should be saved in `Output directory`. – user7860670 Dec 03 '17 at 10:11
  • @tambre https://en.m.wikipedia.org/wiki/Man_page – hymced Dec 03 '17 at 10:14
  • @VTT yes that is what I have done, no .i file generated anywhere – hymced Dec 03 '17 at 10:15
  • @hymced Oh, you simply meant a man page. – tambre Dec 03 '17 at 10:15
  • They should be in `Output directory`, that path to output directory can be found at `Project Properties` ➡ `General` tab. – user7860670 Dec 03 '17 at 10:17
  • @VTT yes here `\$(SolutionDir)$(Configuration)`, but they are not, neither Release not Debug :( – hymced Dec 03 '17 at 10:53
  • So what is in there instead? Compilation should produce either .obj files (normal) or .i files (preprocessed) for each translation unit. – user7860670 Dec 03 '17 at 10:57
  • I have got 1 .obj for each one of my .cpp, 1 .idb, 1 .pdb, 1 .log – hymced Dec 03 '17 at 10:59
  • -_- Please add comments with downvotes – hymced Dec 03 '17 at 11:03
  • @hymced - Didn't downvote, but can guess that it comes from the fact that VTT's solution works for everyone else. Change one option to Yes, click Compile, done. – Bo Persson Dec 03 '17 at 12:58
  • @Bo I am sorry but it does not work for me. I have a clean install, just made the last update, it does not work, that it. So the spirit here is to downvote when a provided solution does not work ?? that's just great... – hymced Dec 03 '17 at 13:34
  • @hymced - Your problem here is that you claim that it doesn't work, but everyone else can easily test the solution (like in my comment) and see that it in fact *does* work. A question with a non-reproducible problem can of course get a few downvotes. – Bo Persson Dec 03 '17 at 13:52

1 Answers1

4

I have not been able to make the preprocessed .i file using the built in option of Visual Studio 2017, but using the command line method it works:

  1. open a command prompt of the Developer Command Prompt for Visual Studio
  2. use cd to navigate to this location: $(SolutionDir)$(ProjectName). In my case it is something like that: C:\Users\UserName\Source\Repos\Project1\Project1

  3. use this command: CL /P /C Source1.cpp

Now I get my Source1.i next to my source. Thanks all for your very helpful inputs. I will report this on the Visual Studio developer community instead.

hymced
  • 570
  • 5
  • 19
  • Once you do report it, make sure to link the report in your answer. – tambre Dec 03 '17 at 14:49
  • the report is here: https://developercommunity.visualstudio.com/content/problem/159405/c-unable-to-output-a-preprocessed-file-using-the-p.html – hymced Dec 03 '17 at 14:52
  • @hymced Did you faced this error LNK 1104...cannot open file /Debug.xxx.obj like that? – RaHuL May 09 '20 at 14:19