Export (0) Print
Expand All
Expand Minimize

Compiler Error C3391

Error Message

'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must be a non-nullable value type

A generic type was instantiated incorrectly. Check the type definition. For more information, see Nullable and Generics (Visual C++).


The following sample, using C#, creates a component that contains a generic type, with certain constraints that are not supported when authoring generic types in Visual C++ 2005. For more information, see .Constraints on Type Parameters (C# Programming Guide).

// C3391.cs
// compile with: /target:library
// a C# program
public class GR<N>
where N : struct {}

The following sample generates C3391.

// C3391_b.cpp
// compile with: /clr
#using <C3391.dll>
using namespace System;
value class VClass {};

int main() {
   GR< Nullable<VClass> >^ a = 
      gcnew GR< Nullable<VClass> >();   // C3391 can't be Nullable
   GR<VClass>^ aa = gcnew GR<VClass>();   // OK

Community Additions

© 2014 Microsoft