somma/_MyLib

RegistryUtil.cpp 컴파일 에러

somma opened this issue · 1 comments

somma commented

C2733 에러가 다수 발생한다.

1> RegistryUtil.cpp
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(243): error C2733: 'lstrcatA': second C linkage of overloaded function not allowed
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\winbase.h(2706): note: see declaration of 'lstrcatA'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(247): error C2733: 'vsprintf': second C linkage of overloaded function not allowed
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\ucrt\stdio.h(1467): note: see declaration of 'vsprintf'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(249): error C2733: 'wsprintfW': second C linkage of overloaded function not allowed
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\winuser.h(309): note: see declaration of 'wsprintfW'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(380): warning C4005: 'StrCatBuff': macro redefinition
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\dontuse.h(192): note: see previous definition of 'StrCatBuff'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(382): warning C4005: 'wvnsprintf': macro redefinition
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\dontuse.h(190): note: see previous definition of 'wvnsprintf'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(383): warning C4005: 'wnsprintf': macro redefinition
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\dontuse.h(191): note: see previous definition of 'wnsprintf'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(486): warning C4005: 'StrNCpy': macro redefinition
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\dontuse.h(189): note: see previous definition of 'StrNCpy'
1>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\shlwapi.h(494): warning C4005: 'StrCpyN': macro redefinition
1> c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\dontuse.h(181): note: see previous definition of 'StrCpyN'

somma commented

원인

RegistryUtil.cpp 에서 사용하는 Shlwapi.h 에 문제가 발생하는 API 가 다른 헤더파일에도 중복정의되어있다.

#include "Shlwapi.h"
#pragma comment(lib, "Shlwapi.lib")

Shlwapi.h 에 다른 windows 헤더에 중복정되는 C linkage function 들이 다수 있다. 다른 헤더와 중복 참조를 하지 않으면 문제가 안생기겠지만 중복 참조하게 되는경우 C2733 에러가 발생한다. 이런 상황을 방지하기 위해 Shlwapi.h 에 중복함수 정의를 막기위한 전처리기가 준비되어있다.

//
// Users of this header may define any number of these constants to avoid
// the definitions of each functional group.
//
//    NO_SHLWAPI_STRFCNS    String functions
//    NO_SHLWAPI_PATH       Path functions
//    NO_SHLWAPI_REG        Registry functions
//    NO_SHLWAPI_STREAM     Stream functions
//    NO_SHLWAPI_GDI        GDI helper functions

해결방안

#inclue NO_SHLWAPI_STRFCNS 를 사용해서 에러를 제거할 수 있다.