Warning C4278: 'GetCurrentDirectory': identifier in type library 'GCRComp.tlb' is already a macro; use the 'rename' qualifier

I'm migrating a VC++ 6.0 application to Visual studio 2008. I've fixed all the migration errors, now I'm fixing the warnings. The following warning occurs in almost 40 instances, Even after so much trial and errors and research in google, I'm not able to fix this warning.

Please find below an instance of the C42778 Error, If I get some help to fix the one below, I'll follow the same approach to fix the remaning 39 warnings.

Warning C4278: 'GetCurrentDirectory': identifier in type library 'GCRComp.tlb' is already a macro; use the 'rename' qualifier

------Code snippet from ZipFile1.h -------

#import "GCRCOmp.tlb" rename_namespace("GCRTools") // C42778


------Code snippet from gcrcomp.tlh -------

Virtual HRESULT __stdcall raw_GetCurrentDirectory {
/*[out]*/ BSTR * dirname,
/*[out, retval]*/ VARIANT_BOOL * okStatus)=0;
virtual HRESULT __stdcall get_currentDirectory {
/*[out, retval]*/ BSTR * pVal)=0;


__declspec(property(get=GetcurrentDirectory))
_bstr_t currentDirectory;


VARIANT_BOOL GetCurrentDirectory (
BSTR * dirname);
_bstr_t GetcurrentDirectory ();

------Code snippet from gcrcomp.tli-------

inline VARIANT_BOOL IFtp1::GetCurrentDirectory(BSTR * dirname){
    VARIANT_BOOL _result = 0;
    HRESULT _hr = raw_GetCurrentDirectory(dirname, &_result);
    if(FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
    return _result;
}

inline _bstr_t IFtp1::GetCurrentDirectory(){
    BSTR _result = 0;
    HRESULT _hr = get_currentDirectory(&_result);
    if (FAILED(_hr) _com_issue_errorex(_hr, this, __uuidof(this));
    return _bstr_t(result, false);
}

Any help to fix this warning is greatly appreciated. Thanks a lot in advance!

Answers


It because GetCurrentDirectory is already defined in Windows SDK. It is a part of ANSI/Unicode API conversion. The way to fix is undefined it before import GCRCOmp.tlb. Try this:

#pragma push_macro("GetCurrentDirectory")
#undef GetCurrentDirectory
#import "GCRCOmp.tlb" rename_namespace("GCRTools")
#pragma pop_macro("GetCurrentDirectory")

Need Your Help

Create a copy of video (.mp4) file android

android

I would like to copy an existing video file to another video file.

jpa merge not working

java orm jpa merge

I have a problem with merging of objects using JPA. My code goes like this.