description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||
---|---|---|---|---|---|---|---|
Learn more about: Compiler Warning (level 1) C4397 |
Compiler Warning (level 1) C4397 |
11/04/2016 |
|
|
6346fdc2-dbbf-4fba-803a-32b0d0a707be |
DefaultCharSetAttribute is ignored
xref:System.Runtime.InteropServices.DefaultCharSetAttribute is ignored by the Microsoft 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 {
public:
void method() {
ImportDefault(IntPtr::Zero);
}
};
[StructLayout(LayoutKind::Explicit)]
public ref struct StructDefault1{};
public ref class ClassDefault1{};