473,503 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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: ra******@beckman.com
== Email 2: ra******@mindspring.com
==
==
== 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."
==
================================================== ====================
================================================== ====================

Nov 16 '05 #1
2 1551
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.
Nov 16 '05 #2
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" <ra******@beckman.com>
From: "Robert A Riedel" <ra**********@beckman.com>
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: ra******@beckman.com
== Email 2: ra******@mindspring.com
==
==
== 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."
==
================================================== ====================
================================================== ====================



Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2288
by: K.M. Jr. | last post by:
Hi all, Consider this line - char s = "\0"; Does this initialize all array elements to zero ? Thanks.
20
7057
by: Petter Reinholdtsen | last post by:
Is the code fragment 'char a = ("a");' valid ANSI C? The problematic part is '("a")'. I am sure 'char a = "a";' is valid ANSI C, but I am more unsure if it is allowed to place () around the...
3
2529
by: Eric Laberge | last post by:
Aloha! I've been reading the standard (May '05 draft, actually) and stumbled across this: 6.7.1 Initialization §20 "If the aggregate or union contains elements or members that are aggregates...
15
4834
by: Charles Sullivan | last post by:
Assume I have a static array of structures the elements of which could be any conceivable mixture of C types, pointers, arrays. And this array is uninitialized at program startup. If later in...
0
1229
by: Robert A Riedel | last post by:
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...
1
1585
by: Bern McCarty | last post by:
I am using MEC++ in VC 7.1. I had a method on a __gc object that looked like this: __property System::UInt32 get_MyProperty(void) { System::Byte __pin * pinBytes = &m_byteArray; // entire...
15
26394
by: thinktwice | last post by:
char a = { 0 } is it ok?
6
34758
by: Kannan | last post by:
Hi, I have question about character array initialization. In section 6.7.8 paragraph number 21, it's given that "If there are fewer initializers in a brace-enclosed list than there are...
24
2152
by: DomoChan | last post by:
the code below will compile in visual c++ 2003, but im not sure its valid. unsigned char myString = ""; after this line executes, all the bytes within myString are indeed set to '0's' but is...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.