${fileDirname}/*.cpp gives output in single-quotes

29 views Asked by At

With the following tasks.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "Build with g++ 10.5.0",
            "command": "/usr/bin/g++-10",
            "args": [
                "-fdiagnostics-color=always",
                "-std=c++20",
                "-g",
                "${fileDirname}/*.cpp",
                "-o",
                "${fileDirname}/rooster"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /usr/bin/g++-10"
        }
    ]
}

the command being printed on console when running Terminal->Run Build Task->Build with g++ 10.5.0, is:

/usr/bin/g++-10 -fdiagnostics-color=always -std=c++20 -g '/home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/*.cpp' -o /home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/rooster

, which gave the compile error:

Starting build...
/usr/bin/g++-10 -fdiagnostics-color=always -std=c++20 -g '/home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/*.cpp' -o /home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/rooster
g++-10: error: /home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/*.cpp: No such file or directory
g++-10: fatal error: no input files
compilation terminated.

Build finished with error(s).

 *  The terminal process failed to launch (exit code: -1). 
 *  Terminal will be reused by tasks, press any key to close it. 

I found it strange that there are single quotes for one part of the command, but not for the other. So I ran the command without the single-quotes:

/usr/bin/g++-10 -fdiagnostics-color=always -std=c++20 -g /home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/*.cpp -o /home/arnabx17/Random/c_plus_plus/cpp_20_Prac_12/rooster

and it gave no compile error, and the output worked.

I also see that this is not an issue on another machine that I regularly use, but only on this machine (I just recently installed gcc, g++ compilers on this new machine). I see that it is not a compiler issue, but an issue with how VScode is substituting the value in place of ${fileDirname}/*.cpp, since the command ${fileDirname}/main.cpp works (main.cpp is the file I wanted to compile).

Any reason why this may be happening, and how to resolve this? I already happened across this post, but mine is different.

0

There are 0 answers