0

Am trying to include CString in my cpp file but am getting this error if i include afxinet.h

"windows.h already included afxv_w32.h"

These are my header files :

#include stdafx.h

#include shlwapi.h

#include Tlhelp32.h

#include hooks.h

#include stdio.h

#include common1.h

#include SafeLogger.h

#include io.h

#include tinyxml.h

#include winsock.h>

#pragma comment(lib, "Ws2_32.lib")

#include afxinet.h

I havent included the gaurds in stack to display here.

how to solve this issue and get to include CString in my file

user1858925
  • 59
  • 1
  • 10
  • Sounds like something doesn't have include guards that should, or your include order is incorrect. – lc. Jan 24 '13 at 06:22
  • Possibly related http://stackoverflow.com/questions/5392302/windows-h-already-included-error?rq=1 – lc. Jan 24 '13 at 06:23
  • Also, http://stackoverflow.com/questions/1017814/error-windows-h-already-included-mfc-apps-must-not-include-windows-h?rq=1 – lc. Jan 24 '13 at 06:24
  • I don't think 'afxinet.h' will work without 'afx.h' – 9dan Jan 24 '13 at 06:45

3 Answers3

2

Why are you adding afxinet.h if you want CString?

You should include atlstr.h to get CString - particularly if your project isn't MFC based.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
1

Use /showIncludes option in C++ settings (Under Advanced). This will show how headers are being included (in tree-format). As another suggestion, you should include only files that are needed.

Ajay
  • 18,086
  • 12
  • 59
  • 105
0

By including < afx.h >, you should be able to use CString class in cpp file.

#include <afx.h>
#include <iostream>

using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    CString str("Santosh");
    wcout << LPCTSTR(str) << endl;
    return 0;
}

Additionally, you will need to define _AFXDLL preprocessor