0

I'm trying to build a c/c++ file and generate an assembly listing file at the same time. I can't get it to work. I can build it on the command line and generate the file but I can't do it from within the VSCode build. My tasks.json file is as follows:

"tasks": [
       {

            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gcc.exe",
            "args": [
                "-g",
                "-S",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "My Build Task"
        },
    ],
    "version": "2.0.0"
}
rioV8
  • 24,506
  • 3
  • 32
  • 49
KernelSanders
  • 23
  • 1
  • 6
  • What is the output? Did you get any error message? – Furkan Çetinkaya Nov 29 '20 at 23:11
  • 1
    `cppbuild` is an invalid value for `type`, it pops up regularly, what is the source of this? – rioV8 Nov 29 '20 at 23:12
  • I don't get any errors on the output. The .c file builds to an .exe file and I can step through and debug it with no issues. – KernelSanders Nov 29 '20 at 23:15
  • The source for this is a simple hello world .c file. – KernelSanders Nov 29 '20 at 23:15
  • 1
    A command like `gcc -S foo.c -o foo.exe` will generate an assembly source file but write it to a file named `foo.exe` (which will of course not actually execute). If you're able to run the file then I suspect what you're running is not what gcc created. – Nate Eldredge Nov 29 '20 at 23:42
  • 1
    [How do you get assembler output from C/C++ source in gcc?](https://stackoverflow.com/q/137038) mentions both `-S` and `-save-temps` (which can save asm while still creating a `.o` or `.exe`) – Peter Cordes Nov 29 '20 at 23:51
  • the -save-temps works on the command line but not through the tasks file. – KernelSanders Dec 01 '20 at 00:36

0 Answers0