We recommend using Visual Studio 2017

Compiler Error C3166


The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C3166.

pointer' : cannot declare a pointer to an interior __gc pointer as a member of 'type'

The compiler found an invalid pointer declaration (a __nogc pointer to a __gc pointer.). This syntax may be supported in a future release.

C3166 is only reachable using /clr:oldSyntax.

The following sample generates C3166:

// C3166.cpp  
// compile with: /clr:oldSyntax  
#using <mscorlib.dll>  
using namespace System;  
__gc struct G {  
   int __gc* __nogc* p;   // C3166  
public __gc class H {  
   Int32 __gc* __nogc* p;   // C3166  
public __value struct I {  
   int __gc* __nogc* p;   // C3166  
public __value class J {  
   int __gc* __nogc* p;   // C3166  
int main() {  
   G* pG = new G;  
   H* pH = new H;