Author Topic: Error in CB but not in VC2005  (Read 3310 times)

Offline briahn06

  • Single posting newcomer
  • *
  • Posts: 7
Error in CB but not in VC2005
« on: May 15, 2006, 11:15:58 am »
I tried to build this file:
#if !defined(XMLSETTINGS_H)

//#import "msxml4.dll" named_guids raw_interfaces_only

// CXMLSettings window

#include <atlbase.h>

class CXMLSettings
// Construction
XmlDocPtr = NULL;
cstrConfigFile = "";

// Implementation
void SetSettingsFile(CString cstrFile) { cstrConfigFile = cstrFile; };

long GetSettingLong(CString cstrBaseKeyName, CString cstrValueName, long lDefaultValue);
long SetSettingLong(CString cstrBaseKeyName, CString cstrValueName, long lValue);

CString GetSettingString(CString cstrBaseKeyName, CString cstrValueName, CString cstrDefaultValue);
long SetSettingString(CString cstrBaseKeyName, CString cstrValueName, CString cstrValue);

BOOL DeleteSetting(CString cstrBaseKeyName, CString cstrValueName);

MSXML2::IXMLDOMDocument2Ptr XmlDocPtr;
CString cstrConfigFile;

CString* ParseKeys(CString cstrFullKeyPath, int &iNumKeys);
void UnloadXML() { XmlDocPtr = NULL; };
MSXML2::IXMLDOMNodePtr FindNode(MSXML2::IXMLDOMNodePtr parentNode, CString* pCStrKeys, int iNumKeys, BOOL bAddNodes = FALSE);


in CB with the atl libraries and such included, but I seem to get this error (among many more):

error: redeclaration of C++ built-in type 'short'

in the crtdefs.h located in the VC\includes folder.
When I build this exact same file in VC2005, it builds properly with only 1 warning and 0 errors.  Any ideas?

Offline JFalcon

  • Single posting newcomer
  • *
  • Posts: 7
Re: Error in CB but not in VC2005
« Reply #1 on: August 23, 2006, 04:57:29 am »

   There are a few things you need to look at.  1) Your #include paths.  Some #include files take precedence over another if found first;  2) any pre-defined pre-processor macros.  Some of them are always created for you by default (such as those by the friendly Code::Blocks Wizards) or those which are created for you in your other IDE; 3) any pre-processor macros that you might need to actually add to your own code to work with a particular source file.

   When in doubt, check the file that complains: chances are you will still need to do a bit of 'grep' work to find the file that is causing the problem.  Looking at the header file where the problem appears, does it appear around an "#if #else #endif" block?  What caused that to be included?

   If you go back to your VS project and examine it's pre-defined symbols, are they all defined in your Code::Blocks project too?  Keep in mind there may be some (as I have seen commented out) compiler specific directives that may cause other issues.



Offline jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: Error in CB but not in VC2005
« Reply #2 on: August 28, 2006, 09:04:14 am »
error: redeclaration of C++ built-in type 'short'

in the crtdefs.h located in the VC\includes folder.

If you're including Visual C files it won't work.