|
the problem might be because you have a syntax error (a missing ; or a brackets { } misplaced) before #including globals.h
|
|
|
|
|
I didn't miss any ';' at all. Infact it's system(Simulation Engine's) file. What to do? Here is the complete code for globals.h.
#ifndef DELTA_GLOBALS
#define DELTA_GLOBALS
#include <string>
#include <dtCore/export.h>
namespace dtCore
{
DT_CORE_EXPORT void SetDataFilePathList( const std::string& pathList );
DT_CORE_EXPORT std::string GetDataFilePathList();
DT_CORE_EXPORT std::string GetDeltaDataPathList();
DT_CORE_EXPORT std::string GetDeltaRootPath();
DT_CORE_EXPORT std::string GetEnvironment(const std::string& env );
DT_CORE_EXPORT void SetEnvironment(const std::string& name, const std::string& value);
DT_CORE_EXPORT std::string FindFileInPathList(const std::string &fileName);
}
#endif //DELTA_GLOBALS
|
|
|
|
|
so you didn't read my post !!!
i said the error is NOT in the globals.h file itself but around it.
when you #include a header, it's as if its content was copied/pasted at the location of the #include directive. so if you have an arror in a file #included before that one, on in the including file itself, you might see such errors in files you actually didn't modified.
also, if it's a system file, be sure to #include <> rather than #include ""
|
|
|
|
|
Here is my complete listings where the 'globals.h' is included.
#include "HelloWorld.h"
#include <dtCore/globals.h>
#include <dtCore/object.h>
#include <dtCore/orbitmotionmodel.h>
#include <dtCore/scene.h>
#include <osgDB/FileUtils>
#include <dtCore/dt.h>
#include <dtABC/application.h>
If include HelloWorld.h like u said (<helloworld.h>) it shows me error which says Cannot open include file. No such file or Directory. What to do?
|
|
|
|
|
I can't believe HelloWorld.h being a system header.
BTW usually non-system headers includes (like #include "HelloWorld.h" ) follows the system ones. Your snippet shows the opposite.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Not HelloWorld.h. It's globals.h.
|
|
|
|
|
I was suggesting (the same toxcct did) to put #include "HelloWorld.h" at the end of your include list.
Often problems originate in slightly different places with respect the one the misbehaviour shows up.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
what happens if you #include "HelloWorld.h" after every other system includes ?
|
|
|
|
|
It gives me errors if I include after all the system files.
d:\myprojects\myprojects\myprojects\helloworld.cpp(13) : error C2533: 'HelloWorld::{ctor}' : constructors not allowed a return type
d:\myprojects\myprojects\myprojects\helloworld.cpp(65) : error C2264: 'HelloWorld::HelloWorld' : error in function definition or declaration; function not called
|
|
|
|
|
Please post the code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Here is the code.
#include "HelloWorld.h"
#include <dtCore/globals.h>
#include <dtCore/object.h>
#include <dtCore/orbitmotionmodel.h>
#include <dtCore/scene.h>
#include <osgDB/FileUtils>
#include <dtCore/dt.h>
#include <dtABC/application.h>
#include <dtCore/deltawin.h>
HelloWorld::HelloWorld(const std::string& configFilename):dtABC::Application(configFilename),mText(0),mOrbitMotionModel(0)
{
if(osgDB::findDataFile(configFilename).empty())
{
GenerateDefaultConfigFile();
}
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::Config()
{
mText = new dtCore::Object("Text");
mText->LoadFile("HelloWorld.flt");
GetScene()->AddDrawable( mText.get() );
dtCore:: Transform camPos;
camPos.SetLookAt( 0.0f, -100.0f, 20.0f,
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f);
GetCamera()->SetTransform(camPos);
mOrbitMotionModel = new dtCore::OrbitMotionModel(GetKeyboard(),GetMouse());
mOrbitMotionModel->SetTarget(GetCamera());
}
int main()
{
dtCore::SetDataFilePathList( ".;" + dtCore::GetDeltaDataPathList());
dtCore::RefPtr<HelloWorld> app = new HelloWorld( "config.xml" );
app->Config();
app->Run();
return 0;
}
|
|
|
|
|
And the HelloWorld.h code?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
#include <dtABC/application.h>
#include <dtCore/refptr.h>
namespace dtCore
{
class Object;
class OrbitMotionModel;
}
class HelloWorld: public dtABC::Application
{
public:
HelloWorld(const std::string &configFilename);
protected:
virtual ~HelloWorld();
public:
virtual void Config();
private:
dtCore::RefPtr<dtCore::Object> mText;
dtCore::RefPtr<dtCore::OrbitMotionModel> mOrbitMotionModel;
}
|
|
|
|
|
Well, I cannot spot the error. The code seems OK.
Anyway, I insist, the right place for #include "HelloWorld.h" is at the bottom of the list.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
you're missing a ; after the closing } of the class definition.
a class definition is like this :
class C {
}<code>;</code>
|
|
|
|
|
Then it probably means you have errors in that file. Post some code (and please, use the code block tags).
|
|
|
|
|
Here is the complete listing.
#include "HelloWorld.h"
#include <dtCore/globals.h>
#include <dtCore/object.h>
#include <dtCore/orbitmotionmodel.h>
#include <dtCore/scene.h>
#include <osgDB/FileUtils>
#include <dtCore/dt.h>
#include <dtABC/application.h>
#include <dtCore/deltawin.h>
HelloWorld::HelloWorld(const std::string& configFilename):dtABC::Application(configFilename),mText(0),mOrbitMotionModel(0)
{
if(osgDB::findDataFile(configFilename).empty())
{
GenerateDefaultConfigFile();
}
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::Config()
{
mText = new dtCore::Object("Text");
mText->LoadFile("HelloWorld.flt");
GetScene()->AddDrawable( mText.get() );
dtCore:: Transform camPos;
camPos.SetLookAt( 0.0f, -100.0f, 20.0f,
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f);
GetCamera()->SetTransform(camPos);
mOrbitMotionModel = new dtCore::OrbitMotionModel(GetKeyboard(),GetMouse());
mOrbitMotionModel->SetTarget(GetCamera());
}
int main()
{
dtCore::SetDataFilePathList( ".;" + dtCore::GetDeltaDataPathList());
dtCore::RefPtr<HelloWorld> app = new HelloWorld( "config.xml" );
app->Config();
app->Run();
return 0;
}
|
|
|
|
|
Where is line 29 at? That's the one that eventually caused the compiler to complain?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello all.
I have this code with something error occured:
//------------------------------------------
#include "iostream"
using namespace std;
class aa
{
public:
aa()
{
aa(5);
}
aa(int t)
{
x = t;
}
void print()
{
cout << x << endl;
}
private:
int x;
};
int main()
{
aa t;
t.print();//this can't output "5", why?
return 0;
}
///---------------------------
As is descriped above, thanks in advance!
If we dream, every thing is possible!
modified on Thursday, June 5, 2008 3:31 AM
|
|
|
|
|
Could you please elaborate the problem ? What's wrong ?
And please use the "code block" option when posting code (all of that is clearly explained in the posting guidelines).
|
|
|
|
|
(excluding << and >> operators usage!) He creates a temporary object (calling aa(5) ) inside the default constructor, probably he wanted to initialize x with 5 instead.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
and WHAT IS the error occuring dude ?!
BTW, i see a problem in your cout statements.
cout cannot use the >> operator. it uses << operator only, so change your code into this :
void print() {
cout << x << endl;
}
and everywhere you're doing such a mistake...
|
|
|
|
|
He creates a temporary object (calling aa(5) ) inside the default constructor (leaving garbage inside x ), probably he wanted to initialize x with 5 instead.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
thanks dear. but i saw your answer, so no need to flood the thread
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toxcct wrote: so no need to flood the thread
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|