g++ error: expected ; before it
I think you just need to add 'typename' to tell the compiler that MapSuperClass::const_iterator is a type:
typename MapSuperClass::const_iterator it = mMap->begin(); // line 50
Because MaySuperClass is a class template parameter, the assumption is that the const_iterator member is a field. Using typename
informs the compiler that it is in fact a type.
More information: http://en.wikipedia.org/wiki/Typename#A_method_for_indicating_that_a_dependent_name_is_a_type
GCC template : error : expected ',' or '...' before ' ' token
There's a lot of issues with the code that prevent from compilation:
- The functions
fibon_seq
andis_size_ok
are not defined. You have to define them in this file or include them with a#define
macro. - The code appears to be including the
std
namespace. You need to include this withusing namespace std;
, usually at the beginning of the code, after library includes. - The variable
msg
is passed as an argument in a function, but it's not defined. - This function call
display_message(msg, size);
is being passed the wrong argument.size
is an integer, but the function expectsvector<int>
.
5.ocnst
is a typo. It should beconst
.
Linux g++ compile error: error: expected ',' or '...' before '||' token
or
is reserved in C++ (§2.12/2 C++11). It's an alternative token for ||
(§2.6/2), so you can't use it for an identifier. Rename the variable from or
to something else to solve this problem.
Cf. this existing post for further details on alternative tokens.
error: expected ';' before '' token
Probably you are missing a semicolon at the end of what's on the previous line.
If you have no code before that line, then it is a missing semicolon at the end of one of your included header files.
For example you can reproduce this error using:
#include <vector>
class C
{
}
std::vector< std::vector<int> > data;
c - creating a makefile causes error expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
Looking at your pastebin your files that are being compiled are corrupted and not the same as the ones you've show us here.
According to the pastebin output, the mazeDisplay.h
file contains this text:
extern void drawMaze(char maze[21][21]);
extern void drawGraph(Node *firstNodeOfGraph);
extern int openDisplayWindow();
extern int closeDisplayWindow();
extern void drawNodeWithColor(int c1, int r1, int color);
extern void drawEdgeWithColor(int c1, int r1, int
(comments etc. are elided by the preprocessor). Note how this file ends right in the middle of the function declaration for drawEdgeWithColor()
.
This is why you're seeing the syntax error you get: because the end of this last line in the mazeDisplay.h
file is missing.
All I can suggest is that when you copied these files over to your virtual machine, you somehow didn't copy the entire file but missed the last few characters.
It's usually better to use something like scp
to copy files. But another important lesson here is that when asking for help be sure to provide the actual files you're working with, cut and pasted from the system where you're compiling them, rather than publishing other files you think are the same... they might not be. People cannot help you if the information given to them is not accurate.
In addition to that there's also something odd in your mazes.c
file; it looks like you tried to insert the contents of the graphSet.h
file directly into the mazes.c
file; you don't need to do that and you should definitely not include both of them.
error: expected `;' before ‘T’
It looks like the name of your class time
is a reserved word and cannot be used. If you change it to mytime
, like I did here, you'll find it works as expected.
I'm going to have to find out why time
is a reserved word or what's going on.
Apparently your class name conflicts with a global ::time
struct, which would make sense as to why it isn't accepted by the compiler.
If you really want to use a time
class you should create your own namespace and put it in there.
namespace tony { class time {}; } int main() { tony::time t; }
This should remove the name conflict.
g++ compiler error: expected ‘,’ or ‘...’ before ‘’ token only on Mac
It's a compiler bug in Apple's version. I think you can work it around by naming your parameter and adding parents around your default value:
void printother(const std::vector<std::pair<float,float> >& ref = (std::vector<std::pair<float,float> >()));
^ ^ ^
C++ Game Programming. Error: expected ')' before ':' token
As already pointer out, you should try including C++'s string.
#include <string>
However, if that's your problem, the compiler should have said string
is not in the std
namespace.
To me it looks like the compiler doesn't know about the ::
namespace operator.
The possible cause is that you're using a C compiler instead of a C++ compiler.
C doesn't have a notion of namespace, and it has no std::string
.
Make sure your source file's extension is a C++ one (like .cpp
) as opposed to C (.c
).
Depending on your compiler, you might need to tell it you mean C++ and not C.
If you're using gcc, try g++ instead.
Adding C++ code in C program - expected ‘,’ or ‘...’ before ‘this’
Those weren't keywords in C, they are in C++.
You will have to rename those parameters before the code will compile in C++.
You may run into other porting issues related to C++'s stricter type checking before you are done.
Another option is to keep the C and C++ code in separate files, and use extern "C"
in the C++ code for every function call that must cross the boundary. Since your C code extensively uses nested functions and other features not permitted in C++, this is probably your quickest approach.
Related Topics
Cuda - Confusion About The Visual Profiler Results of "Branch" and "Divergent Branch" (2)
Change The Escape Sequence Generated by Xterm for Key Combinations
Aosp Build Error: Unrecognized Module Type "Hidl_Package_Root"
Git Is Not Ignoring File Permission Changes
Arch/X86/Include/Asm/Unistd.H VS. Include/Asm-Generic/Unistd.H
Printing Floating Point Numbers in Assembler
Nohup Create New Files Nohup.Out by Day
Centos Cgconfig Fails to Start
Expect Script Error Send: Spawn Id Exp4 Not Open While Executing
Why Does Cat <<< $Var1 Lose Newlines
Grep,How to Search for Exact Pattern
Copying Local Git Config into Docker Container
Run Hydra (Mpiexec) Locally Gives Strange Ssh Error
Phony Targets for Parallel Execution of Make
How to Enable Spell Checker in Google Colab (Colab Operates on Linux Os)
Can't Run Dmidecode on Docker Container
Copy Failed: Stat /Var/Lib/Docker/Tmp/Docker-Builder700869788/Private: No Such File or Directory
Selinux Prevented Httpd(Usr/Sbin/Httpd) Write Access to /Var/Www/HTML/Bookings/Templates_C