Including PortableDevice.h causes a lot of errors

280 Views Asked by At

I read this article and just created a cpp console project in VisualStudio 2017 including some headers.

stdafx.h:

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>

#include <PortableDeviceApi.h>
#include <PortableDevice.h>

All I've done is this and I got a lots of errors.

오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2143   구문 오류: ','이(가) '&' 앞에 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2803   'operator =='에는 클래스 형식의 정식 매개 변수가 적어도 하나는 있어야 합니다.  ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2805   이항 'operator =='에 매개 변수가 너무 적습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2065   'pkeyOne': 선언되지 않은 식별자입니다.  ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2228   '.pid' 왼쪽에는 클래스/구조체/공용 구조체가 있어야 합니다.    ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2065   'pkeyOther': 선언되지 않은 식별자입니다.    ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C2228   '.fmtid' 왼쪽에는 클래스/구조체/공용 구조체가 있어야 합니다.  ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C3861   'IsEqualIID': 식별자를 찾을 수 없습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 35  
오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 36  
오류  C2143   구문 오류: ','이(가) '&' 앞에 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 36  
오류  C2803   'operator !='에는 클래스 형식의 정식 매개 변수가 적어도 하나는 있어야 합니다.  ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 36  
오류  C2805   이항 'operator !='에 매개 변수가 너무 적습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 36  
오류  C2065   'pkeyOne': 선언되지 않은 식별자입니다.  ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 36  
오류  C2065   'pkeyOther': 선언되지 않은 식별자입니다.    ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\propkeydef.h 36  
오류  C2065   'GUID_DEVINTERFACE_WPD': 선언되지 않은 식별자입니다.    ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 18  
오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 18  
오류  C2440   '초기화 중': 'initializer list'에서 'int'(으)로 변환할 수 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 18  
오류  C2065   'GUID_DEVINTERFACE_WPD_PRIVATE': 선언되지 않은 식별자입니다.    ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 23  
오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 23  
오류  C2374   'DEFINE_GUID': 재정의. 여러 번 초기화했습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 23  
오류  C2440   '초기화 중': 'initializer list'에서 'int'(으)로 변환할 수 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 23  
오류  C2065   'GUID_DEVINTERFACE_WPD_SERVICE': 선언되지 않은 식별자입니다.    ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 28  
오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 28  
오류  C2374   'DEFINE_GUID': 재정의. 여러 번 초기화했습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 28  
오류  C2440   '초기화 중': 'initializer list'에서 'int'(으)로 변환할 수 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 28  
오류  C2065   'WPD_EVENT_NOTIFICATION': 선언되지 않은 식별자입니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 404 
오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 404 
오류  C2374   'DEFINE_GUID': 재정의. 여러 번 초기화했습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 404 
오류  C2440   '초기화 중': 'initializer list'에서 'int'(으)로 변환할 수 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 404 
오류  C2065   'WPD_EVENT_OBJECT_ADDED': 선언되지 않은 식별자입니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 408 
오류  C4430   형식 지정자가 없습니다. int로 가정합니다. 참고: C++에서는 기본 int를 지원하지 않습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 408 
오류  C2374   'DEFINE_GUID': 재정의. 여러 번 초기화했습니다.   ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 408 
오류  C2440   '초기화 중': 'initializer list'에서 'int'(으)로 변환할 수 없습니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 408 
오류  C2065   'WPD_EVENT_OBJECT_REMOVED': 선언되지 않은 식별자입니다. ConsoleApplication1 c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\portabledevice.h 412 
...

I have no idea to handle this since I am not familiar with Windows development and this is first time to create an Windows app. How can I solve this problem or how can I get an information about this?

1

There are 1 best solutions below

2
isp-zax On

Update: I left the initial answer, but I think it's irrelevant. Are you positive that you included files in the following order as in your question?

#include <PortableDeviceApi.h>
#include <PortableDevice.h>

As this doesn't produce any errors in the empty console app, however, should you reverse the order as below, the list of errors matches your question:

#include <PortableDevice.h>
#include <PortableDeviceApi.h>

All above assuming you have SDK installed.

Initial answer (most likely irrelevant to the problem) This is just a guess since your question is incomplete (as it doesn't have full code to reproduce the problem), but I think you might have forgotten to add proper main returning int which could result in C4430 to your console application or some other simple error as next one in your error list C2143. Some missing ; after a statement or int in definition or declaration.

Perform binary search in your source code by commenting parts of it to see what exactly causes the errors and if you can't find it yourself in a small code snippet, post your source code in your question.