C++ just a syntax error: syntax error : identifier - c++

I feel so dumb right now:
moveSequence look(COORD xyBeatle, fieldd &field);
what could be so wrong about that, to give a syntax error?
error C2061: syntax error : identifier 'fieldd'
What I am trying to do is pass an a reference of a class fieldd to look() via:
moveSequence sequence = look(xy, m_field);
It doesn't seem to recognize the type field
Actually I am being littered with errors all about things that should be type field are having type int assumed ect..
This is after a long week of refactoring and not even getting back to the point of compiling so I cannot tell what change immediately caused this.
edit: now I am noticing that intellisense is underlining, for only a moment, intermittently the places where the compiler is throwing real errors..... I disabled PCH and rebuilt but this didn't work.
edit2:
The variable name was NOT the problem, that was one of the first things I Tried.
edit3:
I was finally able to catch one of the intellisense errors and it read "identifier "fieldd" is undefined" before shortly changing to "class fieldd" I think this might be a problem with the headers. this guys problem was headers: http://www.gamedev.net/topic/555445-solvederror-c2061-syntax-error--identifier-t3dobject/

field appears to be a type name. Use a different variable name.

We really need more code to identify your problem but I wonder if you need to forward declare fieldd since you have refactored the code into different files, perhaps the headers are not included correctly or the dependencies no longer make sense?
changing your declaration to: moveSequence look(COORD xyBeatle, class fieldd &field)
might give you more information.

fieldd is not recognized as a type if I understand well.
Does fieldd foobar works over the line triggering the error? If not it's likely that you're missing the include declaring fieldd.

Related

C++ missing information in compiler error

I'm trying to compile a Visual C++ 2013 project but the compiler is throwing this mysterious error:
Error 1 error C2338: The C++ Standard doesn't provide a hash for this type.
It does not tell me which class that is missing a hash, nor does it tell me in which file the error occurs. Rather, it links me to a line in the file xstdef which seem to be one of the compiler's libraries.
How can such critical information have been left out of the error message and how do I go about figuring out which class that is the perpetrator?
If you look at the Output tab, it will sometimes list more lines of code (e.g. template instance generated from file/line.) This can help you find the real problem - it will usually be from somewhere trying to USE the class, and not point directly to the class definition.
If you've made recent changes, you can try bisecting or stashing to find the change that introduced the error.

Using for_each_process() in my program prevents me from compiling, compiler says semicolon expected?

I'm trying to write a very simple piece of code for a class, but I'm just stumped as to why I can't compile it. Sorry if this is a duplicate or silly question, but I couldn't find any others that answered this for me. My full program is pasted below. When I try to compile, I get the following error:
test.c: In function 'main':
test.c:7:27: error: expected ';' before '{' token
Here's the code:
#include<stdio.h>
#include<linux/sched.h>
#include<linux/kernel.h>
int main(){
struct task_struct *task;
for_each_process(task){
printf("I found task: %d\n", task->pid);
}
return 0;
}
I feel like I'm missing something painfully obvious, can anyone point out what the problem is here? I've tried initializing the 'task' object as NULL and using a simpler printf statement that just prints 'test', but nothing I've tried has fixed this compilation error.
The macro has been moved to <linux/sched/signal.h> in this commit c3edc4010e9d102eb7b8f17d15c2ebc425fed63c in 2017. (https://github.com/torvalds/linux/commit/c3edc4010e9d102eb7b8f17d15c2ebc425fed63c).
(For someone who has trouble in compiling for this reason.)
The preprocessor token you are using for_each_process is either not defined, or not defined to do what you think it does.
Every C++ compiler I've used can be told to dump the post-preprocessing output. If you pass the flag that makes this happen when building your source file, you'll see the code that the compiler is seeing and screwing up on.
gcc -E clang -E or the /E flag in visual studio (heh) for example.
As #Ulrich has mentioned above, apparently that macro is only available within the kernel. Attempting to read <linux/sched.h> directly and determine this is challenging, as there are many, many ifdef/endif pairs.

C++ weird compilation errors, something deeply wrong

I'm trying to work with a 3rd party C++ source code (TORO framework for robotic SLAM, you may get it via svn with: svn co https://www.openslam.org/data/svn/toro), by trying to encapsulate it in a DLL to be used in my C# code later.
However I get a variety of errors just by including the source files into my project.
For example for the following code
void TreePoseGraph<Ops>::revertEdge(TreePoseGraph<Ops>::Edge * e){
revertEdgeInfo(e);
Vertex* ap=e->v2;
e->v2=e->v1;
e->v1=ap;
}
I get the following errors:
error C2182: 'revertEdge' : illegal use of type 'void'
error C2470: 'AISNavigation::TreePoseGraph::revertEdge' : looks like a function d
definition, but there is no parameter list; skipping apparent body
error C2072: 'AISNavigation::TreePoseGraph::revertEdge' : initialization of a function
Of course the first thing I did was checking if it is included (revertEdge) in the right headers, and in the stdAfx.h and of course it was present everywhere.
Moreover, IntelliSense recognizes everything, can point me to the source of everything, so it seems that nothing is missing from the project. Yet, I get a huge amount of errors of the similar kind.
I'm sure I'm doing something very wrong here right at the beginning, which causes all this dump of nonsense error messages (well there may be 1-2 reasonable, but the rest is just the result of the avalance). Could you give any suggestion what could result in getting such a huge set of error messages?
Just a guess, but you might need a typename before the TreePoseGraph<Ops>::Edge in order to tell the compiler that Edge is actually a type, i.e.,
void TreePoseGraph<Ops>::revertEdge(typename TreePoseGraph<Ops>::Edge * e)
{
// ...
}
I think that this is how it should look:
template<class Ops> void TreePoseGraph<Ops>::revertEdge(TreePoseGraph<Ops>::Edge * e) {
// ...
}

Inheritance, expected type-specifier before error

Well I'm trying to figure out inheritance in c++, and I'm getting a compile time error error: expected type- specifier before 'Pawn'. I get this on the following line
Piece * p = new Pawn(c);
I removed this code because I got worried about people using my code for the assignment I was doing at the time. I apologize if this caused any inconvenience, if you have any specific questions contact me.
I'm aware there may be some other errors but This is the one I'm at a loss with. Thanks in advance for your help!
In the file that has the statement
Piece * p = new Pawn(c);
you seem to forget to include corresponding header files.
I had encountered a similar problem. It turned out I copied and pasted from a previous class and forgot to update my #ifndef statement at the top of my new header file. The compiler was ignoring my new header file because I told it to. D'oh!

VS2008 internal compiler error

I'm consistently running into an internal compiler error while attempting to switch from MSVC6 to MSVC 2008. After much work commenting out different parts of the program, I've traced the error to two lines of code in two different CPP files. Both of these CPP files compile successfully, yet somehow have an effect on whether or not the error manifests in other files.
Both of those lines involve instantianting several complex, nested templates. They also appear to be the only places in the app that use an abstract class as one of the template parameters. That said, I'm far from certain that the issue involves either abstract classes or templates, it's just the most obvious thing I've noticed. I can't even be sure that these lines are significant at all. Here's what they look like, though:
m_phDSAttributes = new SObjDict<RWCString, SIDataSource>(&RWCString::hash);
So we've got SObjDict, a templatized dictionary class, SIDataSource, an abstract interface, and the parameter is a pointer to a static member function of RWCString.
I've been playing around with the code some, and I can occasionally get the error to move from one CPP file to another (for instance, I changed a bunch of template declarations from using class to typename), but I can't find any rhyme or reason to it.
I'm at a loss as to how to debug this issue further. The exact error output by the compiler (with the name of my source file changed) is below. There is no mention of it anywhere on the internet. I'm pretty desperate for any advice on how to proceed. I don't expect someone to say "oh, you just need to do XYZ", but a pointer on how to debug this sort of issue would be greatly appreciated.
1>d:\Dev\webapi.cpp : fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'f:\dd\vctools\compiler\utc\src\p2\p2symtab.c', line 5905)
The trick seems to be disabling precompiled headers. I have no idea why that solves the problem, and it's very unfortunate since my build time for the affected project has gone from less than 30 secs to nearly 5 minutes, but at least I can progress forward.
It's a reasonable bet to assume that p2symtab.c is (part of) the symbol table code. This would immediately explain how the upgrade caused it; this code has been rewritten. (Remember the 255 character length warnings of VC6?)
In this case, there is no new entry in the symbol table, so it's likely a lookup in the symbol table failing spectactularly. It would be interesting to see if the context in which th name lookup happens affects the result. For instance, what happens if you change the code to
typedef SObjDict<RWCString, SIDataSource> SObjDict_RWCString_SIDataSource;
m_phDSAttributes = new SObjDict_RWCString_SIDataSource(&RWCString::hash);
This will force another symbol table entry to be created, for SObjDict_RWCString_SIDataSource. This entry is sort of a symbolic link to the template instantiation. The new name can (and must) be looked up on its own.
Start breaking it down into smaller parts. My first guess is the pointer to the static function is going to be the problem. Can you make a dummy non-template class with the same parameter in the constructor? Does it compile if you don't use an abstract class in the template?
Looks like I'm sending you in the wrong direction, the following compiles fine in 2008:
class thing {
public:
static void hash( short sht ) {
}
void hash( long lng ) {
}
};
class thing2 {
public:
thing2( void (short ) ){}
};
int _tmain(int argc, _TCHAR* argv[])
{
thing2* t = new thing2( &thing::hash );
delete t;
return 0;
}
The principle remains though, remove/replace complex elements until you have code that compiles and you'll know what is causing the problem.
fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'f:\dd\vctools\compiler\utc\src\p2\p2symtab.c
i also observed the same error when i try to build my vs 2005 code to vs 2008. but it happen till i have not installed Service pack of VS 2008...
have you installed Service pack... i think this will resolved your issue....
This typically happens with template instantiation. Unfortunately it could be caused by many things, but 99% of the time your code is subtly invoking undefined behavior.