locked
error C2065: '_T' : undeclared identifier RRS feed

  • Question

  • Hi,

    I'm developing a small application(.exe) for Windows Mobile devices using the Windows Mobile Standard 6 SDK. I work on a XP sp2 laptop and I try to write C++. As far as I can see, I am doing exactly what I found in example code blocks. I have not a clue why I get "error C2065: '_T' : undeclared identifier" when I try to build my code.


    The following is the beginning of my .cpp file.
    #include "stdafx.h"
    #include "log.h"
    #include <stdio.h>
    #include <tchar.h>
    #include <string>
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    FILE* MyLog::m_fp;
    
    MyLog::MyLog()
    {
    	m_fp = _tfopen(_T"\\Program Files\\MyEngineLog.txt", _T"a+");
    	if (NULL == m_fp)
    	{
    		cerr << _T"problem opening file" << endl;
    	}
    }

    Any ideas will be much appreciated.
    Monday, July 13, 2009 10:22 AM

Answers

  • try:    _T("a+")
    • Marked as answer by CppPiet Monday, July 13, 2009 11:21 AM
    Monday, July 13, 2009 11:03 AM
  • Hi Piet,

    _T() is a macro and should be used like this,

    // Provide () for _T.
    m_fp = _tfopen(_T("\\Program Files\\MyEngineLog.txt"), _T("a+"));

    Regards,
    Jijo.


    http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
    • Marked as answer by CppPiet Monday, July 13, 2009 11:21 AM
    Monday, July 13, 2009 11:04 AM

All replies

  • try:    _T("a+")
    • Marked as answer by CppPiet Monday, July 13, 2009 11:21 AM
    Monday, July 13, 2009 11:03 AM
  • Hi Piet,

    _T() is a macro and should be used like this,

    // Provide () for _T.
    m_fp = _tfopen(_T("\\Program Files\\MyEngineLog.txt"), _T("a+"));

    Regards,
    Jijo.


    http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
    • Marked as answer by CppPiet Monday, July 13, 2009 11:21 AM
    Monday, July 13, 2009 11:04 AM
  • Thank you guys,

    That was quite a silly mistake.
    Monday, July 13, 2009 11:23 AM