Have gcc i.e. GNU c++ compiler ignore shebang

Oct 3, 2022 at 12:15am
This error urges act on how to make GNU c++ ignore shebang:

1
2
m.cpp:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/vim 
Please do favour solve it. thanks much
Last edited on Oct 3, 2022 at 12:16am
Oct 3, 2022 at 12:29am
Maybe do chmod +x m.cpp and have the first line read
//usr/bin/env vim "$0"
Oct 3, 2022 at 5:45am
@abdul
I am unsure why you have this obsession with doing weird things to C++ code.

You have been advised many times to either get yourself a more powerful preprocessor or write your own program to translate between the weird C++ variants you want and C++ you can actually compile.

All the strange things you are trying to do can be fixed by doing just that.


In this case, I cannot fathom why you have a C++ source file (designed to be fed into a compiler) with a shebang directive indicating it is actually an executable file loading itself into VIM. Those are orthogonal objectives. The latter objective is just plain odd.
Last edited on Oct 3, 2022 at 5:46am
Topic archived. No new replies allowed.