I keep getting the 2 errors listed below for the line that I have also included below, can someone please tell me why?
Error 1 error C2143: syntax error : missing ';' before '<'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Line:
deque; <string> get_image_filename_list(string foldername);
First of all, try to include header at the beggining of your source file:
#include <deque>
#include <string>
using namespace std;
Then, try to modify your line like:
deque<string> get_image_filename_list(string foldername);
Related
#include <iostream>
using namespace std;
int main()
{
cout<<"hello world!"<<endl;
return 0;
}
I am trying to run this simplest code in vs2010, but I received more than 100 errors when I was compiling it.
f:\vs2010\vc\include\fstream(14): error C2143: syntax error : missing ';' before '*'
f:\vs2010\vc\include\fstream(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\vs2010\vc\include\fstream(16): error C2653: 'ios_base' : is not a class or namespace name
f:\vs2010\vc\include\fstream(16): error C2061: syntax error : identifier 'openmode'
f:\vs2010\vc\include\fstream(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Errors like these. What should I do?
try to include this lab in your code
#include "stdafx.h"
My code:
BlockyWorld.hpp
#ifndef BLOCKYWORLD_H
#define BLOCKYWORLD_H
#include <CImg.h>
namespace logic {
class BlockyWorld {
public:
BlockyWorld( const CImg<float>* heightmap );
};
}
#endif // BLOCKYWORLD_H
BlockyWorld.cpp
#include "BlockyWorld.hpp"
namespace logic {
BlockyWorld::BlockyWorld( const CImg<float>* heightmap ) {}
}
main.cpp
#include <CImg.h>
#include "logic/BlockyWorld.hpp"
//...
CImg<float> heigthMap;
logic::BlockyWorld world( &heigthMap );
//...
I get alot of errors while compiling:
main.cpp:
include\logic\blockyworld.hpp(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
include\logic\blockyworld.hpp(9): error C2143: syntax error : missing ',' before '<'
main.cpp(85): error C2664: 'logic::BlockyWorld::BlockyWorld(const logic::BlockyWorld &)' : cannot convert argument 1 from 'cimg_library::CImg<float>' to 'const int'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
BlockyWorld.hpp & cpp
include\logic\blockyworld.hpp(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
include\logic\blockyworld.hpp(9): error C2143: syntax error : missing ',' before '<'
include\logic\blockyworld.cpp(4): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
include\logic\blockyworld.cpp(4): error C2143: syntax error : missing ',' before '<'
I don't think it's a circular inclusion error which sometimes causes these kinds of errors for me=).
I must be defining constructor wrong or maybe I'm defining implementation wrong? Was searching for an answer for abount an hour now so I would really use an explanation now.
And just to clarify - I'm not a beginner c/c++ programmer but these templates are confusing :(
Have a nice day and thank your for your answers.
CImg appears to be part of the cimg_library namespace.
Either add using namespace cimg_library to the top of your BlockyWorld.hpp file, or change the function signature to use the namespace like so:
BlockyWorld( const cimg_library::CImg<float>* heightmap );
Along with πάντα ῥεῖ's suggestion of matching up your pointer and reference types.
I use Visual Studio 2005
When I compile, I get this error:
Error 1 error C2146: syntax error : missing ';' before identifier 'mDropEndTime'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
struct MB_SYN_DROPITEM_UPDATE : MSGBUF
{
long mCid; // Index
unsigned long mItemIdx; // idx
TIMESTAMP_STRUCT mDropEndTime; // This is error line
};
Why doesn't C++ know TIMESTAMP_STRUCT?
TIMESTAMP_STRUCT is something defined in sqlext.h
You must add
#include <sqlext.h>
Because TIMESTAMP_STRUCT is not part of the C++ standard.
I need to refactor a .dll for a Zinc based Flash application.
After copy&paste a class from the master to the branch, I'm getting some strange compiling errors:
GameInfo.h(15): error C2146: syntax error : missing ';' before identifier 'm_wsVersion'
GameInfo.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
GameInfo.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The addressed code:
// removed the comments
#include "stdafx.h"
#include <string.h>
class GameInfo {
public:
UINT m_uiGameId;
wstring m_wsVersion; // Line 15
UINT m_uiCheckSum;
wstring m_wsFilePath; // Same error report as on line 15
public:
static BOOL createFromFile(wstring path, GameInfo &target); // error "error C2061: syntax error : identifier 'wstring'" thrown
};
I use Visual Studio 2010 and in the IDE itself everything is okay, no syntactical errors or something like that. And as said I did not touch the code, headers seem fine.
Has anyone a clue what about this error?
Try using the string header, and qualifying the namespace:
#include <string>
class GameInfo {
....
std::wstring m_wsVersion;
};
#include <string> is the right standard include in C++ for string classes and use std::wstring.
I strongly recommend AGAINST using a using namespace std; inside one of your headers, as you would force anybody using the header to pull in the std stuff into the global namespace.
I just reorganized the code for a project and now I'm getting errors I can't resolve. This header is included by a .cpp file trying to compile.
#include "WinMain.h"
#include "numDefs.h"
#include <bitset>
class Entity
{
public:
Entity();
virtual ~Entity();
virtual bitset<MAX_SPRITE_PIXELS> getBitMask();
virtual void getMapSection(float x, float y, int w, int h, bitset<MAX_SPRITE_PIXELS>* section);
};
I'm getting these compiler errors for the declaration of Entity::getBitMask():
error C2143: syntax error : missing ';' before '<'
error C2433: 'Entity::bitset' : 'virtual' not permitted on data declarations
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'
There are more similar errors for the next line as well. It seems like bitset isn't getting included but it clearly is? I can't figure out what's going wrong. WinMain.h includes windows.h, and numDefs.h includes nothing.
Using MS Visual C++ 2008.
Declare the bitset as std::bitset<MAX_SPRITE_PIXELS>.
The bitset template is defined in the std:: namespace, so you either need to reference it by it's full name std::bitset or add using namespace std; somewhere before the class declaration.
I think you need to say std::bitset.
Looks like an error in "numDefs.h"