LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-02-2022, 06:41 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
Have gcc i.e. GNU c++ compiler ignore shebang


This error urges act on how to make GNU c++ ignore shebang:

Code:
m.cpp:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/vim
Please do favour solve it. thanks much
 
Old 10-02-2022, 08:15 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,177

Rep: Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272
There is no reason to have a shebang line in a cpp file.
 
Old 10-02-2022, 11:36 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,912
Blog Entries: 1

Rep: Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880
Delete the "shebang"; use Midnight Commander's F4 function to edit files. (Set environment variable EDITOR to your prefererred editor (export EDITOR=/usr/bin/vim)
 
Old 10-03-2022, 12:47 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,253

Rep: Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419Reputation: 7419
what should anybody do with that shebang at all? https://en.wikipedia.org/wiki/Shebang_(Unix)
A c source file is not executable at all, and do not try to make it executable (using a shebang). The syntax of c is different, everything beginning with a # is a preprocessing directive:
https://gcc.gnu.org/onlinedocs/cpp/T...ssing-language

Although you may try to modify that preprocessor to recognize and ignore it (if you wish)

Last edited by pan64; 10-03-2022 at 12:55 AM.
 
Old 10-03-2022, 11:07 AM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,278

Rep: Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346
You don't.
 
Old 10-03-2022, 12:01 PM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,890
Blog Entries: 13

Rep: Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934Reputation: 4934
Quote:
Originally Posted by BudiKusasi View Post
This error urges act on how to make GNU c++ ignore shebang:

Code:
m.cpp:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/vim
Please do favour solve it. thanks much
What exactly is your question?
 
Old 10-03-2022, 04:08 PM   #7
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,169
Blog Entries: 6

Rep: Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847
Quote:
how to make GNU c++ ignore shebang:
Code:
//#!/usr/bin/vim

/*****************
#!/usr/bin/vim
******************/
 
Old 04-01-2023, 04:24 AM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,278

Rep: Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346Reputation: 5346
Quote:
Originally Posted by BudiKusasi View Post
This error urges act on how to make GNU c++ ignore shebang:

Code:
m.cpp:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/vim
Please do favour solve it. thanks much
Did you do this to get m.cpp to open in vim when you double-click on it? You know there are other ways to do that, right?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I have two version of GCC on the same linux system. How do i make the latest GCC version as default C++ compiler? seke Linux - General 9 08-06-2018 09:46 PM
i have ubuntu 16.04 and gcc 5.1.3 default compiler but i need want gcc 4.4 compiler srinivas_k Linux - Newbie 4 07-06-2016 10:29 AM
LXer: GCC 4.9 vs. GCC 5.1 vs. GCC 6.0 SVN Compiler Benchmarks LXer Syndicated Linux News 0 06-08-2015 01:00 PM
GNU Make and GNU GCC DEBUG vs RELEASE compiler options aryan1 Programming 1 01-12-2010 12:29 PM
[logcheck] ignore.d and logcheck.ignore cyberpunx Linux - Software 0 09-18-2005 05:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration