Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


confusing error message

This topic is 5978 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello everyone, I don''t understand this problem. The compiler reports an error, but I can''t fix it. Basically, in the header file, I include the line "ofstream logFile" I need my log file to output to a file. But I keep getting the following error. Any ideas anyone? I can''t see the problem! Any suggestions much appreciated, - Thankyou in advance, kind reagrds #pragma once #include <string.h> ... class CLog { public: CLog(); ~CLog(void); .... // the usual stuff private: .... ofstream logFile; <--- error message refers to this line }; This is the error message: c:\demo\Log.h(48): error C2079: ''CLog::logFile'' uses undefined class ''std::basic_ofstream<_Elem,_Traits>'' with [ _Elem=char, _Traits=std::char_traits ]

Share this post

Link to post
Share on other sites
yes, when i included that at the top of the file I received the following error.

* Warning C4995, ''_OLD_IOSTREAMS_ARE_DEPRECATED'' is a deprecated name, is
* being issued because the old I/O Streams headers iostreams.h et al will no
* longer be supported from VC8. Replace references such as #include
* with #include <iostreams>, using the new, more conformant, I/O
* Streams headers.

Fair enough, since I''m using VC8. However, even when i use
#include <iostream>

I still get an error message referring to the same line as before.
Thanks for the suggestion, but it still doesnt work :-(

Share this post

Link to post
Share on other sites
hehehe... i laugh because i also had the same problem once. i was knocking my head on the table, not seeing what''s wrong. then it hit me.

std::ofstream logFile; 
that should fix it.


Share this post

Link to post
Share on other sites
damn, still no luck! this is driving me crazy!
but thanks for the tip anyway, ill keep trying. :-)

Share this post

Link to post
Share on other sites
Original post by csxpcm
damn, still no luck! this is driving me crazy!
but thanks for the tip anyway, ill keep trying. :-)

what i said didn't help? did it change anything? or do you still get exactly the same error message? that's weird...

here's my CLog class, see if you can get anything from it...


#pragma once

#ifndef _wwELog_H_

#define _wwELog_H_

#include "wwEPrerequisites.h"

#include "wwEString.h"
#include "wwESingletonCleaner.h"

namespace wwE

enum LoggingLevel {
LL_LOW = 1,

enum LogMessageLevel {
LML_LOW = 1,

class CLog
std::ofstream m_oLog;
LoggingLevel m_oLoggingLevel;
bool m_bDebugOutput;

inline char* MessagePriorityIndicator(LogMessageLevel oLMLevel, char *szBuffer);

CLog(const String &sLogName, LoggingLevel oLoggingLevel = LL_NORMAL, bool bDebugOutput = true);

void LogMessage(const String &oMessage, LogMessageLevel oLMLevel = LML_NORMAL);
void LogMessage(LogMessageLevel oLMLevel, const char *szMessage, ...);

#endif // _wwELog_H_


#include "wwELog.h"

namespace wwE
CLog::CLog(const String &sLogName, LoggingLevel oLoggingLevel, bool bDebugOutput)
printf("CLog created (%s, %i, %s).\n", sLogName.c_str(), static_cast<int>(oLoggingLevel), bDebugOutput ? "true" : "false");

m_oLoggingLevel = oLoggingLevel;
m_bDebugOutput = bDebugOutput;

// log the log creation

LogMessage(LML_HIGH, "log (name - '%s', logging level - %i) created", sLogName.c_str(), static_cast<int>(oLoggingLevel));

// log the log destruction

LogMessage(LML_HIGH, "log successfully finished");


printf("CLog destroyed.\n");

void CLog::LogMessage(const String& sMessage, LogMessageLevel oLMLevel)
if (oLMLevel + m_oLoggingLevel >= 4)
tm *pFormattedTime;
time_t oRawTime;
char szBuffer[4] = {'\0'};

// figure out time

pFormattedTime = localtime(&oRawTime);

// display the message on the debugging screen, if asked to

if (m_bDebugOutput)
printf("%s (%i:%i:%i) %s\n", MessagePriorityIndicator(oLMLevel, szBuffer), pFormattedTime->tm_hour, pFormattedTime->tm_min, pFormattedTime->tm_sec, sMessage.c_str());

// log the message

m_oLog << MessagePriorityIndicator(oLMLevel, szBuffer) << " (" << pFormattedTime->tm_hour << ":" << pFormattedTime->tm_min << ":" << pFormattedTime->tm_sec << ") " << sMessage << "\n";

// to make sure the file is written to, instead of the buffer


void CLog::LogMessage(LogMessageLevel oLMLevel, const char *szMessage, ...)
// don't waste time if this message isn't going to be logged anyway

if (!(oLMLevel + m_oLoggingLevel >= 4))

static char szBuffer[4097];
va_list oList;

va_start(oList, szMessage);
vsprintf(szBuffer, szMessage, oList);
LogMessage(szBuffer, oLMLevel);

inline char* CLog::MessagePriorityIndicator(LogMessageLevel oLMLevel, char *szBuffer)
for (int iLoop1 = 0; iLoop1 < static_cast<int>(oLMLevel); iLoop1++) {

for (; iLoop1 < 4; iLoop1++) {
szBuffer[2 - iLoop1] = ' ';

return szBuffer;

and these are my stream related standard includes (of course, most of them aren't used in the above example).

#include <fstream>
#include <iostream>
#include <iomanip>
#include <strstream>
#include <sstream> // for int or float to string conversions

[edited by - shurcool on July 30, 2002 6:18:07 PM]

Share this post

Link to post
Share on other sites
thanks everyone, ill have a look through code posted, and im sure I''ll be able to fix it.
kind reagrds

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!