The CMarkup test MFC project should compile in Visual Studio 6.0 and newer versions without any problems. However, sometimes issues come up. It has been tested on Visual Studio 2003 and 2005 but there are different beta versions and options possible leading to minor differences.

See the following topics for additional information on compiling specific to STL and MSXML versions:


comment posted Compile CMarkup class in Visual Studio.NET

Robin 11-Jul-2006

I tried to compile the CMarkup class in Visual Studio .NET 2003 and it gave an error message "error C2065: 'CStringData', undeclared identifier". Could you shed some light on what minimal changes I could make to make it compile? I did not make any changes to the project settings. What I did was converted my Visual Studio project into a Visual Studio .NET 2003 project. And it gave me this error.

Under default project configuration, the CMarkup test project compiles under my copy of VS.NET 2003. CStringData is a non-public implementation detail of the MFC CString class used to determine the allocated memory available in the CString object. But this developer answered his own question the next day: "afxdtctl.h needs to be included in stdafx.h".


comment posted VS 2005 Compilation with CMarkup 9.0

Nachiappan Narayanan 25-Nov-2007

I am trying to use the new Markup code (9.0 which combines STL & MFC) in Visual Studio 2005, Visual C++ Console Project without MFC dependency. I want to use purely STL, since we are building platform independent code. I set the preprocessor directive MARKUP_STL. The project already has a UNICODE defined. I get the following error:

error C2664: 'bool
CMarkup::AddElem(CMarkup::MCD_CSTR,CMarkup::MCD_CSTR,int)' : cannot convert
parameter 1 from 'const char *' to 'CMarkup::MCD_CSTR'

for this code:

std::string strValue;
strValue = "xyz";
xml.AddElem(strValue.c_str(), "XYZ");

Only this seems to work:

xml.AddElem( _T("HL7Message"));

In a UNICODE build, CMarkup methods will expect const wchar_t * instead of const char *, i.e. wide strings are expected. Without UNICODE, the preferred choice is to use UTF-8 strings which are the same as ASCII strings for characters in the ASCII range. An alternative to _T() for specifying a wide string is L"HL7Message" which might be more portable to non Visual Studio compilers.


comment posted Re: VS 2005 Compilation with CMarkup 9.0

Nachiappan Narayanan 26-Nov-2007

Actually I found the solution. Please add it to the web site documentation for Visual Studio 2005 users. By default, all Visual Studio projects have the UNICODE settings attached. So if you want to use STL with MSVS 2005, do the following:

  • Create a Visual C++ Empty Project (Any other project, will have UNICODE).
  • Create your main source files from scratch, ex: main.cpp
  • Set MARKUP_STL, MARKUP_STDC both in the project->configuration->C++->preprocessor area.
  • Setting up MARKUP_STL alone does not help, since portion of UNICODE is loaded in the markup.h file "define" area. Only setting both, will enable the Standard library with STL.

    Update September 27, 2008: With CMarkup release 10.0, MARKUP_STDC is no longer used because dependency on tchar.h has been removed altogether. See also Unified CMarkup for STL and MFC.