{"action":"created","issue":{"url":"https://api.github.com/repos/hebaishi/linter-gcc/issues/73","repository_url":"https://api.github.com/repos/hebaishi/linter-gcc","labels_url":"https://api.github.com/repos/hebaishi/linter-gcc/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/hebaishi/linter-gcc/issues/73/comments","events_url":"https://api.github.com/repos/hebaishi/linter-gcc/issues/73/events","html_url":"https://github.com/hebaishi/linter-gcc/issues/73","id":169807641,"number":73,"title":"The problem with compiling C with g++, and compiling C++ with gcc","user":{"login":"iRove108","id":12959037,"avatar_url":"https://avatars.githubusercontent.com/u/12959037?v=3","gravatar_id":"","url":"https://api.github.com/users/iRove108","html_url":"https://github.com/iRove108","followers_url":"https://api.github.com/users/iRove108/followers","following_url":"https://api.github.com/users/iRove108/following{/other_user}","gists_url":"https://api.github.com/users/iRove108/gists{/gist_id}","starred_url":"https://api.github.com/users/iRove108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iRove108/subscriptions","organizations_url":"https://api.github.com/users/iRove108/orgs","repos_url":"https://api.github.com/users/iRove108/repos","events_url":"https://api.github.com/users/iRove108/events{/privacy}","received_events_url":"https://api.github.com/users/iRove108/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-08-07T17:51:50Z","updated_at":"2016-08-31T06:58:55Z","closed_at":null,"body":"## Issue\r\n\r\nTo quote from a [Stack Overflow answer](http://stackoverflow.com/a/3206195/4520911):\r\n\r\n> [Rup](http://stackoverflow.com/users/243245/rup) says it best in his comment to another answer:\r\n[...] gcc will select the correct back-end compiler based on file extension (i.e. will compile a .c as C and a .cc as C++) and links binaries against just the standard C and GCC helper libraries by default regardless of input languages; g++ will also select the correct back-end based on extension except that I think it compiles all C source as C++ instead (i.e. it compiles both .c and .cc as C++) and it includes libstdc++ in its link step regardless of input languages.\r\n\r\nWhich I think sums up my problem pretty well.  Say a user wants to use the `linter-gcc` package to lint both C _and_ C++ files:\r\n\r\nIf they set their `execPath` to be `/usr/bin/gcc`, then it is easy to compile any `.c` source files.  However, it is more difficult to compile C++ files since they have to set their compile flags to be `-lstdc++` when using `g++` is really the best for the job.  Then it was suggested in the [Stack Overflow answer I quoted from](http://stackoverflow.com/a/3206195/4520911):\r\n\r\n> However, you should just make your life easier and use g++.\r\n\r\nThis is what the default `execPath` is set to as well.  The problem is (as shown above) that it lints `.c` source files as `.cpp`instead.  We don't want that!  Say you had this in your `.c` file (just an excerpt):\r\n```\r\nchar *my_string = NULL;\r\nmy_string = \"A\";\r\n```\r\nThis C code is very much valid.  Say you compile with `gcc`: `gcc -Wall my_c_file.c` (`Wall` for all warnings).  It works just fine, and no warnings (or errors) are thrown.  However, the linter gives this error:\r\n\r\n> Conversion from string literal to 'char *' is deprecated [-Wc++11-compat-deprecated-writable-strings]\r\n\r\nThe feature of allowing lines like `char *my_string` was only allowed in C++ for compatibility with C (since C++ has the new string literal type as a _constant_ array of `char`).  However, the `g++` compiler will give a warning as if it were C++ code.\r\n\r\nThis is just one of many examples of where issues could arise with the linter when using `g++` to compile our C code.\r\n\r\n## The Solution\r\n\r\nI think the best way to fix this problem would be to allow users to choose a different `execPath` for C and C++ files. In fact, it might be best to make it simpler in the settings page altogether to compile C vs C++ on the settings page (bold text as user input):\r\n\r\n`C Compiler with Flags`: **gcc -Wall**\r\n`C++ Compiler with Flags`: **g++**\r\n\r\nOr you could just stick with the current format and allow users to set a C compiler `execPath`, and a C++ compiler `execPath` on the settings page.\r\n\r\n## Conclusion\r\n\r\nSorry about the length of this long issue (just wanted to be as specific as possible :wink:).  I hope it is reasonable to make these changes (or something along these lines), which I think would solve the problem.\r\n\r\nIn the mean time, have a wonderful day!\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/hebaishi/linter-gcc/issues/comments/243675781","html_url":"https://github.com/hebaishi/linter-gcc/issues/73#issuecomment-243675781","issue_url":"https://api.github.com/repos/hebaishi/linter-gcc/issues/73","id":243675781,"user":{"login":"hebaishi","id":5178138,"avatar_url":"https://avatars.githubusercontent.com/u/5178138?v=3","gravatar_id":"","url":"https://api.github.com/users/hebaishi","html_url":"https://github.com/hebaishi","followers_url":"https://api.github.com/users/hebaishi/followers","following_url":"https://api.github.com/users/hebaishi/following{/other_user}","gists_url":"https://api.github.com/users/hebaishi/gists{/gist_id}","starred_url":"https://api.github.com/users/hebaishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hebaishi/subscriptions","organizations_url":"https://api.github.com/users/hebaishi/orgs","repos_url":"https://api.github.com/users/hebaishi/repos","events_url":"https://api.github.com/users/hebaishi/events{/privacy}","received_events_url":"https://api.github.com/users/hebaishi/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T06:58:55Z","updated_at":"2016-08-31T06:58:55Z","body":"Thank you very much for your kind message. I haven't made the change yet but I will try to do it this week. Apologies but I've just been crazy busy"}}
{"actor":{"display_login":"hebaishi"}}