473,652 Members | 2,935 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_CH ANGE_AUTHORIZED = S"bcsp_page_is_ change_authoriz ed"
;

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

OleDbParameter * retcodeDbParam = // Trust me, the initializer is correct
....
Object * args[] = { BCSP_PAGE_IS_CH ANGE_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::$C onstGCArrayBoun d$0xd62a1d3f$1$ "
(?$ConstGCArray Bound$0xd62a1d3 f$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_CH ANGE_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******@beckma n.com
== Email 2: ra******@mindsp ring.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."
==
== "Criticizin g 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 1562
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******@beckm an.com>
From: "Robert A Riedel" <ra**********@b eckman.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_CH ANGE_AUTHORIZED = S"bcsp_page_is_ change_authoriz ed" ;
OleDbParameter * rcDbParam = // Trust me, the initializer is correct ...
OleDbParameter * retcodeDbParam = // Trust me, the initializer is correct
...
Object * args[] = { BCSP_PAGE_IS_CH ANGE_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::$C onstGCArrayBoun d$0xd62a1d3f$1$ "
(?$ConstGCArray Bound$0xd62a1d3 f$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_CH ANGE_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******@beckma n.com
== Email 2: ra******@mindsp ring.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."
==
== "Criticizin g 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
2304
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
7079
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 string literal.
3
2537
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 or unions, these rules apply recursively to the subaggregates or contained unions. If the initializer of a subaggregate or contained union begins with a left brace, the initializers enclosed by that brace and its matching right brace initialize the...
15
4863
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 the program I wish to return this array to its startup state, can this be accomplished by writing binary zeroes to the entire memory block with memset(). E.g., static struct mystruct_st { int x1;
0
1233
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 // the other .NET related paraphernalia.
1
1602
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 array is now pinned NativeStruct const __nogc* nativeStructP = reinterpret_cast<NativeStruct const __nogc*>(pinBytes);
15
26418
by: thinktwice | last post by:
char a = { 0 } is it ok?
6
34770
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 elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have...
24
2180
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 this really valid c++ or c? where can I find out how this is implemented? Im concerned because I had a 3rd party library wrapper which was
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
1591
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.