I have a program with many files and right now I have a huge bunch of compiler errors which I have a hard time understanding. The only line references I get are references to C++ libraries, such as algorithm or utility.
My question is: how am I supposed to know where the compiler error is? Some line in my code obviously generated an error in a C++ library, but where was it generated? Is there any way to get more info about the compiler errors? It's not like I can debug it, since it's in compile time.
EDIT: I realize this could be difficult to understand. Here are some examples of errors which I have modified for simplicity reasons.
(1) Here the error is on a line which includes std::string and I have no idea where it tries to do something with ClassY.
In file included from [my path]/ClassX.cpp:1:
In file included from [my path]/ClassX.h:4:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:2123:24:
error: invalid operands to binary expression ('my project::ClassY *' and 'const my project::ClassY')
EDIT 2: problem solved. There were in total 31 error lines and note lines. I thought these had nothing to do with the above. However, they were all connected to one single line, which was referenced further down in the error messages:
myvec.erase(std::remove(myvec.begin(), myvec.end(), item), myvec.end());
Related
I'm using Embarcadero C++ Builder 10.1 Berlin Update 2.
I added one file to a project. I tried to build said project and the build failed and reported the following error:
[bcc32 Fatal Error] FileName.cpp(44329): F1008 Out of memory
I have been reading up on errors that can be found via Google and am only finding linker errors. My understanding is that this isn't a linker error as I'm not seeing [ilink32]. I haven't come across any examples of this error.
The file I added has 25 lines in the h file and 64865 lines in the cpp file. The following method takes up 64755 lines of the cpp file.
void __fastcall TFileName::PopulateKeyValueList()
{
SOKeyValueList->Clear();
SOKeyValueList->AddPair("AKey","AValue");
... roughly 64750 more lines like the one above adding pairs to the list
}
This wasn't an issue before I added the file containing 65k lines of code to the project so I believe the appropriate question is, how may I resolve a file containing 65k lines of code causing a [bss32 Fatal Error] F1008 Out of memory error?
It’s generally not a good idea to hard code data (especially so much data in your case) into a source file. You should put key-value pair info in a file and read them out to build the key-value list.
For the error, I guess the compiler you used is just not good enough to handle large source files.
When I compile a project using cross compiler,I come across the following error:
internal compiler error: in decode_addr_const, at varasm.c:2632
Where can I find the varasm.c file?I searched the project directory and cross compiler directory,but I didn't find it.
Thanks for helpping,Light
The compiler maker has that file, and probably won't give it to you.
But as it seems to be an error in the compiler, you can either contact them / file a bug report, or try to avoid the error by changing your code a bit (which is a guessing game, as you don't know how you made it run into the error). Or use another compiler, if there are choices.
I have two short files located in the same directory. The contents of each are shown below.
File test.cpp contains:
int main()
{
#include <test.h>
}
File test.h contains:
syntax_error
Upon compiling test.cpp with either g++ or clang++, I get an error which is expected.
test.cpp:3:11: error: 'test.h' file not found with <angled> include; use
"quotes" instead
#include <test.h>
^~~~~~~~
"test.h"
However, I also get a second error which seems to contradict the first error.
In file included from test.cpp:3:
./test.h:1:1: error: use of undeclared identifier 'syntax_error'
syntax_error
^
Essentially, the first error reports that the compiler cannot find the file test.h, and the second reports a syntax error in the file that the compiler reported it could not find.
These are the only two errors generated.
I understand why the compiler reports the first error and that I should use quotes with #include in this case. Why, though, does the compiler say it cannot find the file when it clearly has found it? And, why would it continue to report errors in the "unfound" file?
This is a feature, not a bug.
The idea is that if the error is trivial (like a missing semicolon), then the compiler will try to continue compiling as if you had already fixed the error. This enables you to fix multiple errors in one go. This is especially useful when compiling your code takes a long time.
Imagine fixing a missing semicolon, recompiling for five hours, just so that the compiler finds another missing semicolon. And then you have to recompile again. That would be very frustrating, no?
Basically, the compiler will try to recover from any errors as far as it is able to, to be able to report as much errors as possible. Most compilers have a flag for this.
Why, though, does the compiler say it cannot find the file when it clearly has found it?
The compiler found the file yes, that's why it gave you a hint to use "" instead of <>. If it hadn't, it might not have given you the hint. Still, the compiler is not allowed to compile your code correctly, because your code is ill-formed.
As an analogy, just because the compiler found a missing semicolon, that doesn't mean that it can just compile the code with that missing character (if it tries to be Standards compliant). It will however recover and try to find other errors, if any.
I have a large amount of code, so I have tried to only include the relevant parts of the code here
My cpp files compiled with no problems when they were included in another cpp file.
I have another file called. This compiled fine before, until I tried to include the files above in
I get undefined reference errors, even though they were defined in the cpp file
What is going on? Is there a linkage error? Do I need to make changes in the makefile?
Using
ASp* asp = new ASp(input);
works for me. Not sure why using
ASp* asp = new ASp::ASp(input);
is a problem. Need to dig further to find out.
Update
The same problem was addressed at using declarations in main (C++). The tool chain for that question is MS Visual Studio. The answers there point out the same problem but there is no explanation of why new Asp::Asp(input); would be of type int*. The error message reported by the OP appears to be a g++ specific error message.
I've got an update function in my game that contains the following code:
void DrawMiniFPSCounter();
DrawMiniFPSCounter();
The DrawMiniFPSCounter() function is declared in a file called miniFPSCounter.cpp, which is part of the build target (I'm using Xcode). When building, I get a linker error saying that the DrawMiniFPSCounter symbol cannot be found. I've tried removing the declaration above and just calling DrawMiniFPSCounter() but that results in a 'symbol not found' error during compilation. Why would the linker have trouble finding this symbol? Is it something to do with the order in which symbols are resolved in the project?
EDIT: I ran the command nm hrMiniFPSCounter.o | grep Draw in my build directory, and got the following output:
00000000 T __Z15DrawMiniCounteriiiii
0002d040 S __Z15DrawMiniCounteriiiii.eh
00000a00 T __Z18DrawMiniFPSCounterv
0002d148 S __Z18DrawMiniFPSCounterv.eh
00000560 t __ZL9DrawDigitiiib
0002d128 s __ZL9DrawDigitiiib.eh
is this normal? Why the extra characters on the end of the function names?
In my experience most common "errors":
Was the file (really) compiled?
Was it (really) linked correctly?
Did you give the function the name you thought you did?
new Namespace issues :)
Are you sure that the miniFPSCounter.cpp file is compiled (/have been incouded in the project in the right way)? I guess what you are experiencing could be caused by a few different things,but in lack of more information I would say: Try to make sure that the cpp file is being compiled (maybe introduce a few syntax errors which would give rise to a compilation error if it is indeed compiled) and when you are sure about that, you can start checking for other stuff (suchas that it is being linked correctly, etc)
Edit: Putting checklist on top.