Compiler Warning (level 1) C4397
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 1) C4397

Error Message

DefaultCharSetAttribute is ignored

DefaultCharSetAttribute is ignored by the Visual C++ compiler. To specify a character set for the DLL, use the CharSet option of DllImport. For more information, see Using C++ Interop (Implicit PInvoke).


The following sample generates C4397.

// C4397.cpp
// compile with: /W1 /c /clr
using namespace System;
using namespace System::Runtime::InteropServices;

[module:DefaultCharSetAttribute(CharSet::Unicode)];   // C4397

[DllImport("kernel32", EntryPoint="CloseHandle", CharSet=CharSet::Unicode)]   // OK
extern "C" bool ImportDefault(IntPtr hObject);

public ref class MySettingVC {
   void method() {

public ref struct StructDefault1{};

public ref class ClassDefault1{};
© 2015 Microsoft