__gc Array Aggregate Initialization Does Not Work As Advertized -- Why?

R

Robert A Riedel

This is a repost of a question that received no answer. In a module DATA.CPP, when attempting to initialize a __gc array as follows:

//
// Begin sample ...
//

//
// Yes, I include all of the correct assemblies, including MSCORLIB.DLL and
all of
// the other .NET related paraphernalia.
//
Object * swmid = // Trust me, the initializer is correct ...
String * BCSP_PAGE_IS_CHANGE_AUTHORIZED = S"bcsp_page_is_change_authorized"
;

OleDbParameter * rcDbParam = // Trust me, the initializer is correct ....

OleDbParameter * retcodeDbParam = // Trust me, the initializer is correct
....
Object * args[] = { BCSP_PAGE_IS_CHANGE_AUTHORIZED,
rcDbParam->Value,
retcodeDbParam->Value,
swmid } ;

//
// End sample ...
//

Where each of the variables above are valid and defined in the module, the
code successfully compiles using VC.NET 2003, however, the following link
errors are returned:

Linking...
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO'
specification
Data.obj : error LNK2001: unresolved external symbol "unsigned long const
pager::data::$ConstGCArrayBound$0xd62a1d3f$1$"
(?$ConstGCArrayBound$0xd62a1d3f$1$@data@pager@@3KB)
Debug/RpaClient.exe : fatal error LNK1120: 1 unresolved externals

Such is not the case when the same array is explicitly instantiated and
initialized as follows:

//
// Begin sample ...
//

//
// All of the variable initializers are the same as before, except now the
array
// is explicitly allocated and initialized ...
//

Object * args[] = new Object * [ 4 ] ;
args[ 0 ] = BCSP_PAGE_IS_CHANGE_AUTHORIZED ;
args[ 1 ] = rcDbParam->Value ;
args[ 2 ] = retcodeDbParam->Value ;
args[ 3 ] = swmid ;

//
// End sample ...
//

The above sample compiles and links without errors or warnings.

Perhaps someone could enlighten me as to the possible cause for the
anomalous behavior?

Perhaps a compiler bug?


--
======================================================================
======================================================================
==
== Bob Riedel
== Beckman Coulter, Incorporated
== PO Box 8000 W-529
== 200 S Kraemer Blvd
== Brea CA 92822-8000
==
== Email 1: (e-mail address removed)
== Email 2: (e-mail address removed)
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
======================================================================
======================================================================
==
== "Effective education is the key to successful democracy."
==
== "Criticizing the actions of others offers so little risk, and
== requires so little effort that it is, without exception, the tool
== of the lazy and of the foolish -- who have neither the intelligence
== to discover, nor the discipline to pursue, a realistic
== alternative."
==
======================================================================
======================================================================
 
T

Tian Min Huang

Hi Robert,

Thanks for your post. I am checking this issue and will update you with my
information.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
K

Keiji Oenoki

Hi Robert,

Unfortunately aggregate init doesn't work inside a namespace. The
workaround is to initialize each element one by one, as you did.

This has been fixed in the latest internal build of the compiler.

--
Keiji Oenoki
Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.


--------------------
Reply-To: "Robert A Riedel" <[email protected]>
From: "Robert A Riedel" <[email protected]>
Subject: __gc Array Aggregate Initialization Does Not Work As Advertized -- Why?
Date: Fri, 25 Jul 2003 10:53:43 -0700

This is a repost of a question that received no answer. In a module
DATA.CPP, when attempting to initialize a __gc array as follows:
//
// Begin sample ...
//
//
// Yes, I include all of the correct assemblies, including MSCORLIB.DLL and
all of
// the other .NET related paraphernalia.
//
Object * swmid = // Trust me, the initializer is correct ...
String * BCSP_PAGE_IS_CHANGE_AUTHORIZED = S"bcsp_page_is_change_authorized"
;
OleDbParameter * rcDbParam = // Trust me, the initializer is correct ...
OleDbParameter * retcodeDbParam = // Trust me, the initializer is correct
...
Object * args[] = { BCSP_PAGE_IS_CHANGE_AUTHORIZED,
rcDbParam->Value,
retcodeDbParam->Value,
swmid } ;
//
// End sample ...
//
Where each of the variables above are valid and defined in the module, the
code successfully compiles using VC.NET 2003, however, the following link
errors are returned:
Linking...
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO'
specification
Data.obj : error LNK2001: unresolved external symbol "unsigned long const
pager::data::$ConstGCArrayBound$0xd62a1d3f$1$"
(?$ConstGCArrayBound$0xd62a1d3f$1$@data@pager@@3KB)
Debug/RpaClient.exe : fatal error LNK1120: 1 unresolved externals
Such is not the case when the same array is explicitly instantiated and
initialized as follows:
//
// Begin sample ...
//
//
// All of the variable initializers are the same as before, except now the
array
// is explicitly allocated and initialized ...
//
Object * args[] = new Object * [ 4 ] ;
args[ 0 ] = BCSP_PAGE_IS_CHANGE_AUTHORIZED ;
args[ 1 ] = rcDbParam->Value ;
args[ 2 ] = retcodeDbParam->Value ;
args[ 3 ] = swmid ;
//
// End sample ...
//
The above sample compiles and links without errors or warnings.
Perhaps someone could enlighten me as to the possible cause for the
anomalous behavior?
Perhaps a compiler bug?
--
======================================================================
======================================================================
==
== Bob Riedel
== Beckman Coulter, Incorporated
== PO Box 8000 W-529
== 200 S Kraemer Blvd
== Brea CA 92822-8000
==
== Email 1: (e-mail address removed)
== Email 2: (e-mail address removed)
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
======================================================================
======================================================================
==
== "Effective education is the key to successful democracy."
==
== "Criticizing the actions of others offers so little risk, and
== requires so little effort that it is, without exception, the tool
== of the lazy and of the foolish -- who have neither the intelligence
== to discover, nor the discipline to pursue, a realistic
== alternative."
==
======================================================================
======================================================================
 
Top