Comments (48)
I have just done a small test and I am getting the same error message twice - once for the cpp file, and once for the h file.
Are you sure you are viewing all errors in the project? You can see all errors by clicking on the Project button at the bottom of the atom window. This should show you the errors in both files.
from linter-gcc.
If I click on the project button, I still only get the one message, but it also displays the CPP filename against the error.
from linter-gcc.
So you get the same message occuring twice. Is that what you are saying?
from linter-gcc.
No, if I've got File selected, I get one error; if I've got Project selected, I get the same one error, but the error shows the filename as well.
from linter-gcc.
Could you send me a screenshot of your atom window? Do you have both files open in atom? They both need to be open for you to see the errors from both files.
from linter-gcc.
It is actually perfectly normal for an error in a header to be shown in the source file. This is because of how the C++ compiler works. The preprocessor is invoked before the compiler, so essentially all #include
statements are expanded (basically the code from the included file is pasted into the current file). Then the compiler is invoked. This is why it looks like the error is in the CPP file.
What I am trying to establish is whether you have both files open or only one. linter-gcc will only show errors for open files. You can find more information about C++ compilation here.
from linter-gcc.
I know how the C++ preprocessor works. :) I have both header and source file open, and there is no error shown in the header file.
from linter-gcc.
Ok. Could you show me the header and source files you are working with? Or maybe create a small code snippet that recreates the problem so I can play with it?
from linter-gcc.
I'll try and do that over the weekend. In (at least some) other compilers, if there is a problem in a header file, it shows you the error at the right line in the right file. It's odd that GCC can't do the same! :)
from linter-gcc.
I'm getting this error in all of my header files: "cc1: error: output filename specified twice".
When I compile the program I get no errors. It only happens inside atom when using linter-gcc.
Sorry I'm somewhat new to github. Should I create a separate issue?
from linter-gcc.
Could you turn on debugging, open the console, copy the linter-gcc command and paste it here?
from linter-gcc.
cc1: error: output filename specified twice
My linter-gcc version is 0.6.8
Is this ok?
from linter-gcc.
You need to open the debugging console by pressing Ctrl+Shift+I
, turn on the debugging options in the linter-gcc configuration page, and copy the linter-gcc command that appears in the console window.
from linter-gcc.
-1458397310067.txt
Here are the log files.
from linter-gcc.
Could you try pasting the command in the above file into a terminal and running it? It looks fine to me.
The command is:
/usr/bin/gcc -Wall -fsyntax-only -c -fmax-errors=0 /home/platwnas/Desktop/Projects/Algorithms/Recursion/tower_of_hanoi/stack.h
from linter-gcc.
$ /usr/bin/gcc -Wall -fsyntax-only -c -fmax-errors=0 /home/platwnas/Desktop/Projects/Algorithms/Recursion/tower_of_hanoi/stack.h
cc1: error: output filename specified twice
It's not linter-gcc's problem, right?
from linter-gcc.
This is very strange. It looks like it's a gcc bug. Could you report the output of gcc --version
and perhaps try updating GCC? Also, which platform are you on? ubuntu?
from linter-gcc.
$ gcc --version
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I'm using ubuntu 15.10
GCC is up-to-date
I ran sudo apt-get install --reinstall gcc
from linter-gcc.
Looks like there's something wrong with your version of GCC. Could you try installing clang and running the above command with clang instead, so substituting clang
for /usr/bin/gcc
?
from linter-gcc.
@MrPlatwnas unfortunately, it looks like the problem you are having is with the compiler itself. Since linter-gcc is simply an interface to GCC, it will simply display whatever GCC reports. If you disagree with me, and think linter-gcc is doing something wrong, please let me know.
@steronydh could you please do the same - paste the linter-gcc command into a terminal and see if you get the same output. If you do, the issue is with GCC itself, and not linter-gcc.
from linter-gcc.
I will give it a try with clang and I will report the outcome. No problem. It should be the compiler's problem, indeed.
from linter-gcc.
I have the same problem (headers errors in c file) quite often too
from linter-gcc.
I'm using platformio, and seeing:
avr-g++.exe (AVR_8_bit_GNU_Toolchain_3.4.5_1522) 4.8.1
from linter-gcc.
@steronydh @Arignir do you get the same issue when your run the linter-gcc command in the terminal?
from linter-gcc.
Yes, but the message indicates that the error is from my header file, and not from my c file.
from linter-gcc.
Sorry, what linter-gcc command?
from linter-gcc.
You need to do the following:
- Turn on debugging messages in the linter-gcc configuration page
- Press
Ctrl+Shift+I
to open the developer tools window - Click on console
- Type in your source file to trigger linter-gcc, and the linter-gcc command will appear in the console window.
from linter-gcc.
To determine the cause of this issue, I have done the following:
- I have created two files
source.cpp
andheader.hpp
. The source file contains no errors, but the header file does (a missing semicolon after a variable declaration). The source file includes the header. - Below is the output of running
g++
on both files:
/tmp/cpp_play$ cat source.cpp
#include <iostream>
#include "header.hpp"
int main(int argc, char* argv[])
{
return 0;
}
/tmp/cpp_play$ cat header.hpp
#include <iostream>
int i
/tmp/cpp_play$ /usr/bin/g++ -std=c++11 -c -Wall -o /dev/null -fmax-errors=0 -I/tmp/cpp_play/include -I/tmp/cpp_play /tmp/cpp_play/source.cpp
/tmp/cpp_play/source.cpp:4:1: error: expected initializer before ‘int’
int main(int argc, char* argv[])
^
/tmp/cpp_play$ /usr/bin/g++ -std=c++11 -c -Wall -o /dev/null -fmax-errors=0 -I/tmp/cpp_play/include -I/tmp/cpp_play /tmp/cpp_play/header.hpp
/tmp/cpp_play/header.hpp:3:5: error: expected initializer at end of input
int i
^
You can see that when you lint the source file, the error appears to occur in the source file, and the same for the header. This makes perfect sense, because the C++ preprocessor does the #include
substitutions before compilation. Therefore, the source file that is compiled actually has the entire contents of the header file, and this is why g++ reports an error in the source file.
My advice to you is to ensure that your headers are all error-free before working on your source files. You can easily test this by #include
ing your header files one by one into a empty source file to determine if one of them has an error.
from linter-gcc.
I understand and appreciate what is happening with the preprocessor. I've got .gcc-flags.json pointing linter-gcc at the same copy of gcc as I'm using to compile the project, and the project compiles with no errors, so I'm at a loss as to why linter-gcc should be showing errors at all!
from linter-gcc.
How are you compiling your project? What build system are you using? And what is the error that you are seeing in linter-gcc that doesn't appear when you compile?
from linter-gcc.
Also, you need to follow the steps I outlined describing how to find the command run by linter-gcc.
from linter-gcc.
@hebaishi I do understand how include works, but it could be cool if errors from the .h file could not be displayd on a .c / .cpp file, because having a red dot with an error like "missing semicolon" on a blank space in a .cpp file is very strange and quite frustrating when you get started with linter-gcc.
It will be much better if the error is not show on a c/cpp file, or if it is only show at the #include line.
(Sorry for english, i'm french ^^)
from linter-gcc.
@Arignir Unfortunately this is how GCC works - the preprocessor runs before the compiler. There might be a setting to get around this, but I doubt it. In any case this is a compiler issue and has nothing to do with linter-gcc.
from linter-gcc.
I'm using platformio which compiles the Arduino project fine.
from linter-gcc.
@hebaishi When gcc pop the error, the file is indicate. Why not just parse this to pop the error on the good file and not always on the current file ?
from linter-gcc.
@Arignir This is exactly what GCC does already. That is what I tried to explain in the long post above with the two sample files.
from linter-gcc.
@steronydh I will have a play with platformio and get back to you.
from linter-gcc.
@hebaishi >____<
We're not arrived :D
So, when there is an error in a hpp file, gcc points out that the error is on the hpp file. BUT, linter - gcc shows it in the cpp file, not in the hpp file. Is it possible to only show errors that GCC points out to be on this file, so that errors from hpp file will not be saw in cpp file ?
Thanks in advance, and sorry for my bad english ><
from linter-gcc.
@Arignir I really do not think that is possible. I could be wrong, but I seriously doubt it. Expansion of #include
directives is fundamental to the way the compiler works. The directives are always expanded BEFORE compilation, so the compiler doesn't know where the error has come from.
from linter-gcc.
Okey, let's have a test:
I have helloworld.c, with content:
#include "helloworld.h"
int main()
{
printf("Hello World !\n");
return (0);
}
And helloworld.h, with content
#ifndef HELLO_WORLD_H_
# define HELLO_WORLD_H_
# include <stdio.h>
Oh shit ! An error, just here !
#endif /* !HELLO_WORLD_H_ */
Let's now compile with the command gcc helloworld.c -I./
(I'm using gcc 5.3)
Here is the output :
In file included from helloworld.c:1:0:
helloworld.h:6:1: error: unknown type name ‘Oh’
Oh shit ! An error, just here !
^
helloworld.h:6:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘!’ token
Oh shit ! An error, just here !
Don't you see these beautiful "helloworld.h" in the error output ? ;)
from linter-gcc.
Looks like we have found an inconsistency in the way GCC reports errors. In my test case, GCC reports an error in the source file, even though it's actually in the header. In the example you have given, you are right - the error is reported as coming from the header file.
Your input has been helpful in identifying the problem, which is in the case of linting on-the-fly (where linter-gcc actually lints a temporary file), the temporary filename has to be substituted for the original file, but that has to leave any header errors alone. I will update linter-gcc asap and let you know.
from linter-gcc.
Thanks man ! :)
Because i'm using linter-gcc 10h per day, i have tons of ideas to improve it ! Maybe i'll fork / pull request it one day :D
Anyway, thank you !
from linter-gcc.
That's fantastic to hear. If it's easier for you, why don't you create another issue and make a list of some suggested improvements that we can discuss together? As someone who uses it all time, I would love to hear your ideas! Also, it would be great for all the users of linter-gcc (myself included) to benefit from these ideas as soon as possible.
from linter-gcc.
It looks like I need to compile Arduino code with gcc 5.3 to get the improved error reports! ;)
from linter-gcc.
I have made the necessary change. Please update to linter-gcc v0.6.9. Note that a restart of Atom is necessary after updating linter-gcc.
from linter-gcc.
@steronydh @Arignir everything working normally guys?
from linter-gcc.
@hebaishi Didn't had the time to code a lot since the update, so i don't know that much :s
from linter-gcc.
Looking good! Thanks, @hebaishi. Errors in header files are now showing at the exact line in the header file. :) Great fix!
from linter-gcc.
Related Issues (20)
- Linter isn't showing issues (c/c++) HOT 2
- it stops working since the 1.34.0 atom update HOT 2
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 2
- linter-gcc doesn't work HOT 4
- consider this project dead if this issue is not removed (latest commit was on 2017 jan) HOT 3
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 2
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 2
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 1
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 1
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 1
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 1
- Uncaught TypeError: _this.notificationEl.querySelector is not a function HOT 1
- Object.dirname is deprecated.
- Uncaught TypeError: Cannot read property 'binary' of undefined
- Relative paths are relative to Atom's $PWD, not the project root
- string variables not highlighted
- Colors in the linter panel
- I cant install atom linter gcc.its shows"npm WARN deprecated [email protected]: No longer maintained - Use lodash probably npm ERR! Unexpected end of JSON input while parsing near '...MGZNbL9YcGBJl4MH4nrxH' npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\stark siv\.atom\.apm\_logs\2020-12-26T17_25_37_936Z-debug.log" A little help is appreciated,♥ HOT 2
- Just want my GCH address for open sea? HOT 1
- Cannot find module 'tempfile'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linter-gcc.