My compiled file doesn't have an extension

68 Views Asked by At

I'm using VSCode on a MacBook Air. I have installed GCC to compile C files. Basically, when I try to compile a file with the keyboard shortcut, it works perfectly: file.out is generated, but, when I try to compile it using the "Run Code" button, on top-right, the file still gets compiled, but I get generated a file with no extension (which still works, but I don't think I can include it in a .gitignore file)

I tried creating a tasks.json file (in .vscode), in which I specified that I want my file to have a ".out" extension, but, apparently, clicking the "Run Code" button just ignores it.

I have no clue.

1

There are 1 best solutions below

0
ismqdb On

You can add a file with no extension to gitignore, it will get picked up.

If you compile the file with gcc file.c, the default output file is a.out, which is a relic of Unix (MacOS is a derivative of it).

You can use gcc file.c -o outputFile to set the name of the output file. In this case, the generated output file doesn't have an extension. If you add this command to args field in your tasks.json file, you can use Run and Debug tab on the left side to run the program this way.

I am not sure about Code Runner, as I haven't used it.

Alternatively, you can compile and link your project with CMake.