Page 1 of 1

How use stream io in Irrlicht?

Posted: Sat Dec 05, 2009 3:11 pm
by tinhtoitrangtay
Hi, All
I wana use stream io in irrlicht but irrlicht don't allow. when i add to header with
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <cassert>
using namespace std;
when i complied it error and crash VC

----- Rebuild All started: Project: Irrlicht, Configuration: Debug Win32 ------
Deleting intermediate and output files for project 'Irrlicht', configuration 'Debug|Win32'
Compiling...
CGUIWindow.cpp
CGUITreeView.cpp
CGUIToolBar.cpp
CGUITable.cpp
CGUITabControl.cpp
CGUIStaticText.cpp
CGUISpriteBank.cpp
CGUISpinBox.cpp
CGUISkin.cpp
CGUIScrollBar.cpp
CGUIModalScreen.cpp
CGUIMessageBox.cpp
CGUIMeshViewer.cpp
CGUIMenu.cpp
CGUIListBox.cpp
CGUIInOutFader.cpp
CGUIImageList.cpp
CGUIImage.cpp
CGUIFont.cpp
CGUIFileOpenDialog.cpp
Generating Code...
Compiling...
CGUIEnvironment.cpp
CGUIEditBox.cpp
CGUIContextMenu.cpp
CGUIComboBox.cpp
CGUIColorSelectDialog.cpp
CGUICheckbox.cpp
CGUIButton.cpp
CDefaultGUIElementFactory.cpp
irrXML.cpp
CZipReader.cpp
CXMLWriter.cpp
CXMLReader.cpp
CWriteFile.cpp
CTarReader.cpp
CReadFile.cpp
CPakReader.cpp
CNPKReader.cpp
CMountPointReader.cpp
CMemoryFile.cpp
CLimitReadFile.cpp
Generating Code...
Compiling...
CFileSystem.cpp
CFileList.cpp
CAttributes.cpp
CIrrDeviceWinCE.cpp
CIrrDeviceWin32.cpp
CIrrDeviceStub.cpp
CIrrDeviceSDL.cpp
CIrrDeviceLinux.cpp
CIrrDeviceFB.cpp
CIrrDeviceConsole.cpp
sha2.cpp
sha1.cpp
pwd2key.cpp
prng.cpp
hmac.cpp
fileenc.cpp
aestab.cpp
aeskey.cpp
aescrypt.cpp
Generating Code...
Compiling...
pngwutil.c
pngwtran.c
pngwrite.c
pngwio.c
pngtrans.c
pngset.c
pngrutil.c
pngrtran.c
pngrio.c
pngread.c
pngpread.c
pngmem.c
pngget.c
pngerror.c
png.c
jutils.c
jquant2.c
jquant1.c
jmemnobs.c
jmemmgr.c
Generating Code...
Compiling...
jidctint.c
jidctfst.c
jidctflt.c
jfdctint.c
jfdctfst.c
jfdctflt.c
jerror.c
jdtrans.c
jdsample.c
jdpostct.c
jdmerge.c
jdmaster.c
jdmarker.c
jdmainct.c
jdinput.c
jdhuff.c
jddctmgr.c
jdcolor.c
jdcoefct.c
jdatasrc.c
Generating Code...
Compiling...
jdatadst.c
jdarith.c
jdapistd.c
jdapimin.c
jctrans.c
jcsample.c
jcprepct.c
jcparam.c
jcomapi.c
jcmaster.c
jcmarker.c
jcmainct.c
jcinit.c
jchuff.c
jcdctmgr.c
jccolor.c
jccoefct.c
jcarith.c
jcapistd.c
jcapimin.c
Generating Code...
Compiling...
jaricom.c
zutil.c
uncompr.c
trees.c
inftrees.c
inflate.c
inffast.c
deflate.c
crc32.c
compress.c
adler32.c
Generating Code...
Compiling...
strings.cpp
C++ string class
os.cpp
Irrlicht.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
COSOperator.cpp
CLogger.cpp
IBurningShader.cpp
CTRTextureWire2.cpp
CTRTextureLightMapGouraud2_M4.cpp
CTRTextureLightMap2_M4.cpp
CTRTextureLightMap2_M2.cpp
CTRTextureLightMap2_M1.cpp
CTRTextureLightMap2_Add.cpp
CTRTextureGouraudVertexAlpha2.cpp
CTRTextureGouraudNoZ2.cpp
CTRTextureGouraudAlphaNoZ.cpp
CTRTextureGouraudAlpha.cpp
CTRTextureGouraudAddNoZ2.cpp
CTRTextureGouraudAdd2.cpp
CTRTextureGouraud2.cpp
CTRTextureDetailMap2.cpp
Generating Code...
Compiling...
CTRTextureBlend.cpp
CTRGouraudAlphaNoZ2.cpp
CTRGouraudAlpha2.cpp
CTRGouraud2.cpp
CSoftwareTexture2.cpp
CSoftwareDriver2.cpp
CDepthBuffer.cpp
CBurningShader_Raster_Reference.cpp
CD3D9Texture.cpp
CD3D9ShaderMaterialRenderer.cpp
CD3D9ParallaxMapRenderer.cpp
CD3D9NormalMapRenderer.cpp
CD3D9HLSLMaterialRenderer.cpp
CD3D9Driver.cpp
CImageLoaderWAL.cpp
CImageLoaderTGA.cpp
CImageLoaderRGB.cpp
CImageLoaderPSD.cpp
CImageLoaderPPM.cpp
CImageLoaderPNG.cpp
Generating Code...
Compiling...
CImageLoaderPCX.cpp
CImageLoaderJPG.cpp
CImageLoaderBMP.cpp
CImageWriterTGA.cpp
CImageWriterPSD.cpp
CImageWriterPPM.cpp
CImageWriterPNG.cpp
CImageWriterPCX.cpp
CImageWriterJPG.cpp
CImageWriterBMP.cpp
CNullDriver.cpp
CImage.cpp
CFPSCounter.cpp
CColorConverter.cpp
CD3D8Texture.cpp
CD3D8ShaderMaterialRenderer.cpp
CD3D8ParallaxMapRenderer.cpp
CD3D8NormalMapRenderer.cpp
CD3D8Driver.cpp
COpenGLTexture.cpp
Generating Code...
Compiling...
COpenGLSLMaterialRenderer.cpp
COpenGLShaderMaterialRenderer.cpp
COpenGLParallaxMapRenderer.cpp
COpenGLNormalMapRenderer.cpp
COpenGLExtensionHandler.cpp
COpenGLDriver.cpp
CZBuffer.cpp
CTRTextureGouraudWire.cpp
CTRTextureGouraudNoZ.cpp
CTRTextureGouraudAdd.cpp
CTRTextureGouraud.cpp
CTRTextureFlatWire.cpp
CTRTextureFlat.cpp
CTRGouraudWire.cpp
CTRGouraud.cpp
CTRFlatWire.cpp
CTRFlat.cpp
CSoftwareTexture.cpp
CSoftwareDriver.cpp
CVideoModeList.cpp
Generating Code...
Compiling...
CSTLMeshWriter.cpp
CPLYMeshWriter.cpp
COBJMeshWriter.cpp
CIrrMeshWriter.cpp
CColladaMeshWriter.cpp
CSceneNodeAnimatorTexture.cpp
CSceneNodeAnimatorRotation.cpp
CSceneNodeAnimatorFollowSpline.cpp
CSceneNodeAnimatorFlyStraight.cpp
CSceneNodeAnimatorFlyCircle.cpp
CSceneNodeAnimatorDelete.cpp
CSceneNodeAnimatorCollisionResponse.cpp
CSceneNodeAnimatorCameraMaya.cpp
CSceneNodeAnimatorCameraFPS.cpp
CTriangleSelector.cpp
CTriangleBBSelector.cpp
CTerrainTriangleSelector.cpp
CSceneCollisionManager.cpp
COctTreeTriangleSelector.cpp
CMetaTriangleSelector.cpp
Generating Code...
Compiling...
CParticleSystemSceneNode.cpp
CParticleSphereEmitter.cpp
CParticleScaleAffector.cpp
CParticleRotationAffector.cpp
CParticleRingEmitter.cpp
CParticlePointEmitter.cpp
CParticleMeshEmitter.cpp
CParticleGravityAffector.cpp
CParticleFadeOutAffector.cpp
CParticleCylinderEmitter.cpp
CParticleBoxEmitter.cpp
CParticleAttractionAffector.cpp
CParticleAnimatedMeshSceneNodeEmitter.cpp
CWaterSurfaceSceneNode.cpp
CVolumeLightSceneNode.cpp
CTextSceneNode.cpp
CTerrainSceneNode.cpp
CSphereSceneNode.cpp
CSkyDomeSceneNode.cpp
CSkyBoxSceneNode.cpp
Generating Code...
Compiling...
CShadowVolumeSceneNode.cpp
CQuake3ShaderSceneNode.cpp
COctTreeSceneNode.cpp
CMeshSceneNode.cpp
CLightSceneNode.cpp
CEmptySceneNode.cpp
CDummyTransformationSceneNode.cpp
CCubeSceneNode.cpp
CCameraSceneNode.cpp
CBoneSceneNode.cpp
CBillboardSceneNode.cpp
CAnimatedMeshSceneNode.cpp
CXMeshFileLoader.cpp
CSTLMeshFileLoader.cpp
CSkinnedMesh.cpp
CQ3LevelMesh.cpp
CPLYMeshFileLoader.cpp
COgreMeshFileLoader.cpp
COCTLoader.cpp
COBJMeshFileLoader.cpp
Generating Code...
Compiling...
CMY3DMeshFileLoader.cpp
CMS3DMeshFileLoader.cpp
CMD3MeshFileLoader.cpp
CMD2MeshFileLoader.cpp
CLWOMeshFileLoader.cpp
CLMTSMeshFileLoader.cpp
CIrrMeshFileLoader.cpp
CDMFLoader.cpp
CCSMLoader.cpp
CColladaFileLoader.cpp
CBSPMeshFileLoader.cpp
CB3DMeshFileLoader.cpp
CAnimatedMeshMD3.cpp
CAnimatedMeshMD2.cpp
C3DSMeshFileLoader.cpp
CSceneManager.cpp
CMeshManipulator.cpp
CMeshCache.cpp
CGeometryCreator.cpp
CDefaultSceneNodeFactory.cpp
Generating Code...
Compiling...
CDefaultSceneNodeAnimatorFactory.cpp
Generating Code...
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Linking...
LINK : ..\..\bin\Win32-visualstudio\Irrlicht.dll not found or not built by the last incremental link; performing full link
Irrlicht - 1 error(s), 1 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

complied debug mode error and it crash. Now i need it use stream io.

Please help me.

Posted: Sat Dec 05, 2009 6:19 pm
by hybrid
Try the search engine next time, after you've debugged what's the actual cause. Or just try to avoid this massive use of 'using' clauses, which can often lead to name clashes. This should also be the problem here, because Irrlicht's string and std::string interfere if put into the common namespace.
BTW: This is in no way advanced... And the examples use iostream, so you could assume it's working :roll:

Posted: Sat Dec 05, 2009 7:06 pm
by randomMesh
hybrid wrote:try to avoid this massive use of 'using' clauses, which can often lead to name clashes.
That's why the Irrlicht examples shouldn't use 'using'. It serves as a bad example because people just copy it and don't know it's bad to use this directive in a header.

Posted: Sat Dec 05, 2009 9:13 pm
by hybrid
We don't have it in headers there, but it should also be reduced in the last time to some extent. However, the examples don't use that much good coding practice at all, but ti's always a trade-off between readability and good style.

Posted: Sat Dec 05, 2009 9:27 pm
by randomMesh
hybrid wrote:We don't have it in headers there, but it should also be reduced in the last time to some extent.
CDemo.h and CMainMenu.h have 'using irr' for example. This is nothing harmful so far, but newbies may think it is ok to add 'using std' too.
hybrid wrote:However, the examples don't use that much good coding practice at all, but ti's always a trade-off between readability and good style.
Yes, true.

Posted: Sun Dec 06, 2009 7:49 am
by tinhtoitrangtay
Thank you everybody're reply. I try fix it
I add

Code: Select all

#ifdef defined(_HAS_EXCEPTIONS)
#define _HAS_EXCEPTIONS 0  //This is a test. I need fix this problem
#endif

#if defined(_DEBUG)
#define _HAS_EXCEPTIONS 0  //This is a test. I need fix this problem
#else
//#define _HAS_EXCEPTIONS 0  //This is a test. I need fix this problem
#pragma message("This is a bug not enabled /EHsc and it is only test now. I need fix this problem")
#endif
and it can fine works. Now i can use std:string. But i don't know Irrlicht have bug when enabled /EHsc
I hope version 1.7.0 add this options

Code: Select all

#ifdef defined(_HAS_EXCEPTIONS)
#define _HAS_EXCEPTIONS 0  //This is a test. I need fix this problem
#endif

#if defined(_DEBUG)
#define _HAS_EXCEPTIONS 0  //This is a test. I need fix this problem
#else
//#define _HAS_EXCEPTIONS 0  //This is a test. I need fix this problem
#pragma message("This is a bug not enabled /EHsc and it is only test now. I need fix this problem")
#endif
and Irrlicht Engine can use std:string, stream fine works now.
Thanks

Posted: Sun Dec 06, 2009 9:33 am
by hybrid
Which problem does this fix? And why can't you just enable EHsc? There's no reason why you wouldn't be able to use it, unless maybe that it would force you to recompile the engine. So what?
Oh, and never ever cross-post. Things will only be spread over many threads and no one can follow the topic anymore.