Microsoft MVP성태의 닷넷 이야기
VC++: 44. C++/CLI 컴파일 오류 - error C4368: mixed types are not supported [링크 복사], [링크+제목 복사],
조회: 26099
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)
C++/CLI 컴파일 오류 - error C4368: mixed types are not supported

C++/CLI 소스 코드를 빌드하는 데 다음과 같은 오류가 발생한다면?

1>------ Build started: Project: ClassLib, Configuration: Release x64 ------
1>  TestHash.cpp
1>d:\...[생략]...\TestHash.h(41): error C2353: exception specification is not allowed
1>d:\...[생략]...\TestHash.h(40): error C4368: cannot define 'test2' as a member of managed 'ClassLib::TestHash': mixed types are not supported
2>------ Build started: Project: ConsoleApplication1, Configuration: Release x64 ------
2>  ConsoleApplication1 -> D:\...[생략]...\ConsoleApplication1.exe
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

이에 대한 자세한 설명 및 해결책은 다음을 참고하시고.

Some Notes about Mixed Types
; http://blogs.msdn.com/b/branbray/archive/2005/07/20/441099.aspx

간단하게 현재 상황을 풀어보면,
여러분들의 관리 클래스(ref class) 내에서 다음과 같이 C++ 고유의(unmanaged) 타입을 정의했을 때 발생합니다.

#include "CMyCppType.h"

namespace ClassLib 
{
    public ref class TestClass
    {
    private:
        CMyCppType test;
    };
}

해결 방법은, C++ 타입을 그대로 사용할 수 없고 반드시 포인터 참조로 변경해야 합니다. (또는, C++ 타입을 관리 타입으로 변경하거나.)

#include "CMyCppType.h"

namespace ClassLib 
{
    public ref class TestClass
    {
        public:
            TestClass()
            {
                test = new CMyCppType();
            }

            ~TestClass()
            {
                delete test;
            }

        private:
            CMyCppType *test;
    };
}

오랜만에, C++/CLI를 만졌더니 하는 것마다 오류가 발생하는군요. ^^



[이 토픽에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 7/10/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 151  [152]  153  154  155  156  157  158  159  160  161  162  163  164  165  ...
NoWriterDateCnt.TitleFile(s)
1283정성태5/12/201234491.NET Framework: 317. C# 관점에서의 Observer 패턴 구현 [1]파일 다운로드1
1282정성태5/12/201227225Phone: 6. Windows Phone 7 Silverlight에서 Google Map 사용하는 방법 [3]파일 다운로드1
1281정성태5/9/201234271.NET Framework: 316. WPF/Silverlight의 그래픽 단위와 Anti-aliasing 처리를 이해하자 [1]파일 다운로드1
1280정성태5/9/201227389오류 유형: 154. Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, ...'.
1279정성태5/9/201226158.NET Framework: 315. 해당 DLL이 Managed인지 / Unmanaged인지 확인하는 방법 [1]파일 다운로드1
1278정성태5/8/201227528오류 유형: 153. Visual Studio 디버깅 - Unable to break execution. This process is not currently executing the type of code that you selected to debug.
1277정성태5/8/201232489오류 유형: 152. cmd.exe - The system cannot write to the specified device. [2]
1276정성태4/28/201224369Phone: 5. 모든 Marketplace에 윈폰 앱을 등록하는 방법 [1]
1275정성태4/28/201227960개발 환경 구성: 150. 프로세스 실행으로 잠긴 파일이지만, 이름은 변경가능하다는 사실! 아셨나요? [7]
1274정성태4/17/201222632Phone: 4. "Holiday Calendar" 윈폰 응용 프로그램 등록
1273정성태4/6/201226083Phone: 3. 윈도우 폰을 위한 Holiyday Calendar 앱 개발파일 다운로드1
1272정성태4/5/201227194오류 유형: 151. ASP.NET - EcbGetUnicodeServerVariables 코드에서 System.AccessViolationException 예외 발생
1271정성태4/3/201229709Math: 6. 동전을 여러 더미로 나누는 경우의 수 세기 [1]
1270정성태3/29/201224175오류 유형: 150. Visual Studio 2010 원격 디버깅 오류 - Kerberos authentication failed
1269정성태3/27/201238144오류 유형: 149. ODP.NET 오류 - The provider is not compatible with the version of Oracle client
1268정성태3/27/201234416오류 유형: 148. WCF svc 호출 시 HTTP Error 404.17 - Not Found [1]
1267정성태3/16/201232592.NET Framework: 314. C++의 inline asm 사용을 .NET으로 포팅하는 방법 [1]파일 다운로드1
1266정성태3/14/201235681개발 환경 구성: 149. RAID 1 구성 시 하드 디스크 장애 발생 해결에 대한 경험담
1265정성태3/13/201225945VC++: 61. 아이태니엄(IA64: Itanium) 에서 겪은 C++ 포인터 연산 문제 [2]
1264정성태3/10/201245434.NET Framework: 313. WELL512 난수 발생 알고리즘 - C# [5]파일 다운로드1
1263정성태3/9/201224104개발 환경 구성: 148. tinyget 사용법
1262정성태3/8/201244996개발 환경 구성: 147. .keystore 파일에 저장된 개인키 추출 방법과 인증기관으로부터 온 공개키를 합친 pfx 파일 만드는 방법 [1]
1261정성태3/7/201225578Phone: 2. 개발자용 윈도우 폰 7 기기 등록하는 방법
1260정성태3/6/201225710Phone: 1. 윈도폰 7 개발자 (회사) 등록하는 방법 [3]
1259정성태3/4/201237174Windows: 57. 새로 추가된 네트워크 커널 디버깅 및 PowerShell 3.0 [1]
1258정성태3/3/201238742개발 환경 구성: 146. SQL Server 2012에 포함된 LocalDB 기능 소개 [3]파일 다운로드1
... 151  [152]  153  154  155  156  157  158  159  160  161  162  163  164  165  ...