1

I'm playing with Ansi C in visual studio, created the simple Ansi C program (I had to change VS configuration to not use cpp but ansi c)

int a = 0;
int b = 0;

printf("Hello World! \n\n");

system("PAUSE");
return 0;

I compiled it and it generated this:

enter image description here

First of all I was expecting a simple .exe and I don't know why this .ilk and .pdb were created but the question here is how can I see the assembly code generated by the compiled c program?

thanks

RollRoll
  • 8,133
  • 20
  • 76
  • 135

2 Answers2

3

The .ilk is an incremental linking file, which can help speed up linking when you make minor changes to your code, then re-link.

The .pdb is a Program database--use when debugging.

To get the assembly language to which your code translates, you can compile with /Fa.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • very helpful as always Jerry, can you help me to understand what is the compiler visual studio is calling when I build a ansi c program and how I can add the /Fa or any other argument to it? thanks man. – RollRoll Jun 01 '16 at 23:24
  • @ThePoet: I'd at least consider compiling on the command line. Inside the IDE, right click the file in the solution explorer, choose Properties, then go to C/C++ -> Output Files -> Assembler Output and change from "No Listing" to one of the other options (probably "assembly only" or "assembly with source code"). – Jerry Coffin Jun 01 '16 at 23:30
0

Use the Assembler Output setting in the Project Properties.

You can request that Visual Studio show the assembly code for your compiled program by:

  1. Right-clicking on the Project name in the Solution Explorer, and choosing Properties from the menu that appears.
  2. Using the tree-view menu on the left side of the dialog box that appears, click to Configuration Properties > C/C++ > Output Files.
  3. Change the value for Assembler Output from No Listing to Assembly with Source Code (/FAs)
  4. Click OK to close the dialog box.
  5. Rebuild your program.

Now you will have a project-name.asm file, located in the Debug or Release subdirectory of your project directory. That is a text file displaying the source code of your program, and the assembly code that each line was converted into.

librik
  • 3,738
  • 1
  • 19
  • 20